[issue3073] Cookie.Morsel breaks in parsing cookie values with whitespace
New submission from Lawrence Oluyede [EMAIL PROTECTED]: It seems the Cookie module has an odd behavior with whitespaces. According to http://wp.netscape.com/newsref/std/cookie_spec.html and http://en.wikipedia.org/wiki/HTTP_cookie#Cookie_attributes the 'Expires' attribute of the cookie should have this format: Wdy, DD-Mon- HH:MM:SS GMT and this is recognized by all the browsers. The oddity comes when I try to load or create a cookie with that attribute: Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type help, copyright, credits or license for more information. from Cookie import SimpleCookie cookies = SimpleCookie() cookies.load('foo=baz; expires=Sat, 10-Jun-1978 09:41:04 GMT') cookies SimpleCookie: foo='baz' cookies['foo']['expires'] 'Sat,' cookies.load('foo=baz; expires=2008-06-10T09:44:45.963024') cookies['foo']['expires'] '2008-06-10T09:44:45.963024' It really seems the parser breaks on whitespaces. -- components: Library (Lib) messages: 67901 nosy: rhymes severity: normal status: open title: Cookie.Morsel breaks in parsing cookie values with whitespace type: behavior versions: Python 2.5 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3073 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: A lib to build query string...
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Is anybody knows about a function that can build query string from parameter list? I very need that! urllib.urlencode? http://docs.python.org/lib/module-urllib.html#l2h-3888 -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: What Data is Available With a Pickled Object Over a Socket?
milan_sanremo [EMAIL PROTECTED] wrote: I've read the library entry for pickle a couple of times, and I'm still not sure what data is maintained when an item is pickled and sent over a socket. I would not do that if I were you: http://jcalderone.livejournal.com/15864.html Unless you don't care about security -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Cross platform way of finding number of processors on a machine?
Nicholas Bastin [EMAIL PROTECTED] wrote: This is really bad on linux. You really want to parse /proc/cpuinfo because HT 'cpus' are almost useless, and can be bad in situations where you try to treat them as general purpose cpus. I'm not the author of the library. I think you should address these bug reports elsewhere... -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Override 'and' and 'or'
Dekker [EMAIL PROTECTED] wrote: Is it possible to override 'and' and/or 'or'? I cannot find a special method for it... __and__ and __rand__ and __or__ and __ror__ are for binary manipulation... any proposals? If you want to customize the truth value testing you have to implement __nonzero__ __nonzero__( self) Called to implement truth value testing, and the built-in operation bool(); should return False or True, or their integer equivalents 0 or 1. When this method is not defined, __len__() is called, if it is defined (see below). If a class defines neither __len__() nor __nonzero__(), all its instances are considered true. Keep in mind the relation between __len__ and __nonzero__ ps. why you need to customize such a thing? -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Cross platform way of finding number of processors on a machine?
John [EMAIL PROTECTED] wrote: Is there a way to find the number of processors on a machine (on linux/ windows/macos/cygwin) using python code (using the same code/cross platform code)? From processing http://cheeseshop.python.org/pypi/processing/0.34 : def cpuCount(): ''' Returns the number of CPUs in the system ''' if sys.platform == 'win32': try: num = int(os.environ['NUMBER_OF_PROCESSORS']) except (ValueError, KeyError): pass elif sys.platform == 'darwin': try: num = int(os.popen('sysctl -n hw.ncpu').read()) except ValueError: pass else: try: num = os.sysconf('SC_NPROCESSORS_ONLN') except (ValueError, OSError, AttributeError): pass if num = 1: return num else: raise NotImplementedError -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another comparison of Python Web Frameworks
Thomas Wittek [EMAIL PROTECTED] wrote: At least, you missed Turbo Gears :) http://turbogears.org/ For me, it feels more integrated than Pylons. Yeah, so integrated that the next version will be based upon Pylons ;-) ? -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Cross platform way of finding number of processors on a machine?
Paul Boddie [EMAIL PROTECTED] wrote: From the experiments I've done with pprocess [1], pretending that a hyperthreading virtual CPU is as good as a real CPU (or CPU core) tends to be counter-productive: the performance benefits in moving from the utilisation of one to two virtual CPUs are virtually non- existent. We came the same conclusion at work. One of my colleagues has a machine with HyperThreading and he noticed no real performance increase with the processing library altough on my machine (which is a dual Core 2 Duo) the performance boost was definitely there :-) The good side of this is hyperthreading with parallel processes is like using a mono-CPU machine so we don't have to take into account it like if it was an entirely different kind of architecture. -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another comparison of Python Web Frameworks
Jorge Godoy [EMAIL PROTECTED] wrote: What is good, since a lot of good things from Pylons will work with TG and a lot of good TG things will remain (and possibly be compatible with Pylons). If you take a better look at the next version, you'll also see that the major concern was with WSGI support and reinventing / rewriting the wheel (what TG developers don't want to do all the time). Not reinventing the wheel just don't feel as a universal dogma to me. I developed quite a bit with Django and I was glad they started from scratch. On the paper reusing different and existing projects is great but not always is good or done the right way. Anyway I don't know TG at all so I'm speaking in a figurative way. We (Michele, myself and our colleagues) have a series of stuff we need to stick to so the choosing of a web framework ain't that easy. Most of the frameworks are a vision of the author of how to do things from scratch but a framework (by definition an evolution of a library) is not always meant to be used when the scratch is far from your starting point. I'd like to read some commenting of Michele's thoughts, they would be really useful. :-) -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another comparison of Python Web Frameworks
Tim Chase [EMAIL PROTECTED] wrote: Any respectable comparison of Python web frameworks should include evaluation of at least Django and TG. Or at least give good reason why the comparison excludes them. I think you didn't read the foreword of the comparison. That is by no means a comprehensive comparison and is not meant to be one. Is a series of thoughts about the frameworks we already tried (we don't have to decide today) and the ones we experimented with. Django is not completely off the radar because I used it extensively this year but the company has certain requirements and the full stackness of Django is not really one of our needs. Zope is also missing, but I'm not sure Zope qualifies so much as a framework, but as an answer to the question If Emacs were a Python web environment, what would it look like? Zope2/Plone2 is the one framework they are running away from :-) More KISS less over engineering, that's the mantra. Django's built-in templating system is one of those things you either love or you hate. Fortunately, if you're a hater, you can mindlessly swap it out for your template system of choice with minimal fuss. I really, really like Django (and its community and the competence of the developers) and I think it deserves what it has gained and more but we are not here to decide who's the best (there's always no best). -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: A question about subprocess
JD [EMAIL PROTECTED] wrote: How can I do it with the subprocess? You can't. Subprocess is a library to spawn new processes on the local machine. If you want to handle external machines you need something like parallel python: http://www.parallelpython.com/ -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: newb: Question regarding custom exception
crybaby [EMAIL PROTECTED] wrote: Why you specify type and name of the exception in your custom exceptions, It's up to you, if you're interested in the actual exception object you catch it, otherwise not. Take a look at this: http://boodebr.org/main/python/tourist/taking-exception -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
On Sep 3, 10:48 am, [EMAIL PROTECTED] wrote: Hi I am new to Python and have recieved this error message when trying to instantiate an object from a class from another file within the same directory and wondered what I have done wrong. I have a Step.py class: class Step(object) def __init__(self, sName): Initialise a new Step instance self.sName = sName self.depSteps = [] self.remDepSteps = [] self.isCompleted = 0 Then I have created a new file within the same directory called main.py: import Step a = Step(magn) The following however generates the error Traceback (most recent call last): File main.py, line 3, in ? a = Step(magn) TypeError: 'module' object is not callable This is because when you issue import Step you're actually importing the Step _module_, not the Step class inside the module. You can do this in at least two ways: -- import Step a = Step.Step(magn) # access the Step class inside Step module -- or -- from Step import Step # insert in the current namespace the Step class a = Step(magn) -- If anyone could help point me in the right direction, how to fix this problem it would be much appreciated. Chris HTH -- http://mail.python.org/mailman/listinfo/python-list
Re: Gmane's been quiet ...
Grant Edwards [EMAIL PROTECTED] wrote: Posting that were made to mailing lists via gmane? That, I do not know -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Gmane's been quiet ...
Steve Holden [EMAIL PROTECTED] wrote: ... so I was wondering if it's just me who hasn't seen any postings today? I think so, through my usenet server I saw the usual lot of postings -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: New UI Toolkit
Gerdus van Zyl [EMAIL PROTECTED] wrote: Please reply and let your thoughts be known. Is there a need for a new GUI library for python? I think there's no real point in answering this question. You developed a new toolkit because, I'm guessing, you are not fully satisfied by the current ones. In my personal opinion there's no *need* for another toolkit but there is *room* for one, two, hundreds of new toolkits. That's what freedom is for. :-) -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: How to call module functions inside class instance functions?
beginner [EMAIL PROTECTED] wrote: I have encountered a small problems. How to call module functions inside class instance functions? For example, calling func1 in func2 resulted in a compiling error. my module here def func1(): print hello class MyClass: def func2(): #how can I call func1 here. func1() #results in an error [EMAIL PROTECTED] ~ % cat t.py def func1(): print hello class MyClass: def func2(): func1() [EMAIL PROTECTED] ~ % python -c import t [EMAIL PROTECTED] ~ % As you can see there no compiling error, because the syntax is correct, you'll eventually get a runtime error like this: import t c = t.MyClass() c.func2() Traceback (most recent call last): File stdin, line 1, in module TypeError: func2() takes no arguments (1 given) That's because you left out the self argument in the definition of func2(). This version is correct: -- def func1(): print hello class MyClass(object): def func2(self): func1() c = MyClass() c.func2() -- [EMAIL PROTECTED] ~ % python tcorrect.py hello HTH -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a module function visible only inside the module?
beginner [EMAIL PROTECTED] wrote: Is there any equivalent version of C's static function in Python. I know I can make a class function private by starting a function name with two underscores, but it does not work with module functions. The trick for the name mangling does not work at module level. Anyway, if you read the PEP 8 [1] you can correctly write your code following a well known coding standard. A function like this: def _f(): pass is meant to be private, you can also state it in the function's docstring to be more clear, if you want, but it's not necessary For exmaple, __func1 is still visible outside the module. Yes, and _f() will also be. There's no such thing as enforcing encapsulation in Python, even the __method() trick can be easily bypassed if you have to. 1 - http://www.python.org/dev/peps/pep-0008/ HTH -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: how to pass a custom object to re.search?
[EMAIL PROTECTED] wrote: Is it possible to make what I want (to pass a custom object to re.search)? Try to implement __str__() for your object and provide a string representation for it. re.search(str(custom_object)) -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: how to pass a custom object to re.search?
[EMAIL PROTECTED] wrote: and I'm also curious to know if it is possible to do that... :-) Only if re.search() doesn't check for the type of the argument, which it seems it does. -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: How to say $a=$b-{A} ||={} in Python?
beginner [EMAIL PROTECTED] wrote: I'd like to do the following in more succint code: if k in b: a=b[k] else: a={} b[k]=a b.setdefault(k, a) -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: All names in the current module
Torsten Bronger [EMAIL PROTECTED] wrote: How can I get a list with all classes defined in the current module? Thank you! [EMAIL PROTECTED] ~ % cat t.py class A: pass [EMAIL PROTECTED] ~ % python Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type help, copyright, credits or license for more information. import t print dir(t) ['A', '__builtins__', '__doc__', '__file__', '__name__'] Now you have the list of names. To find out if they are actual classes or not you can do this: import inspect for member in dir(t): ... print member, inspect.isclass(getattr(t, member)) ... A True __builtins__ False __doc__ False __file__ False __name__ False HTH -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: All names in the current module
Fabio Z Tessitore [EMAIL PROTECTED] wrote: to get names' list you can simply call globals() Not strictly true. globals() returns the current's scope global vars. If you import a module in the current scope globals() won't display the names inside it. -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple python iteration question
Bryan [EMAIL PROTECTED] wrote: How do I do this? for i, item in enumerate(l): print i, item -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: make images with python
stefano [EMAIL PROTECTED] wrote: I need make some images using python but i'm lost :P http://www.pythonware.com/products/pil/ -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: verify whether str is still callable in Python 2.5.1
Ge Chunyuan [EMAIL PROTECTED] wrote: Once use ActivePython latest version for Python 2.5.1. I happened to find function str is not callable, but it is available for Python 2.5. Can anybody give some comments about it? I don't really understand what your asking. str is a callable, it has always been AFAIK, since it's a type constructor, like int() In [1]: callable(str) Out[1]: True In [2]: str() Out[2]: '' -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: retrieving ATOM/FSS feeds
_spitFIRE [EMAIL PROTECTED] wrote: I'm using feedparser library to parser ATOM/RSS feeds. However, I don't get the entire post! but only summaries! How do I retrieve the entire feed? I believe that the parser library should have support for doing that or the specification should detail how it can be done? Or should I simply get the feed link and do HTML scraping? If the content producer doesn't provide the full article via RSS/ATOM there's no way you can get it from there. Search for full content feeds if any, otherwise get the article URL and feed it to BeautifulSoup to scrape the content. -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: retrieving ATOM/FSS feeds
_spitFIRE [EMAIL PROTECTED] wrote: For the same feed (where the content producer doesn't provide the full article!) I was able to see the complete post in other RSS aggregators (like Blam). I wanted to know how they were able to collect the feed! Perhaps in the feed itself there's the link for the full content feed. -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: check if var is dict
Astan Chee [EMAIL PROTECTED] wrote: I have a variable, I want to check if it is a dictionary or a string. Is there any better way to do this than I've done. How I did it is by doing a .items() and catching a AttributeError that it raises if its not a dictionary. How do i properly do it? One way is: In [6]: isinstance(d, dict) Out[6]: True In [7]: isinstance(ciao, basestring) Out[7]: True This way you won't catch custom classes implementing dict or basestring protocols. In order to do that you can check if it implements the right methods or treat the object as a dict or a string. It depends on what you're trying to achieve. -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: chmod g+ Equivalent
milan_sanremo [EMAIL PROTECTED] wrote: I've read the documentation on os.chmod() and can implement all the standard commands, but what is the syntax for the equivalent of chmod g + to set the group id? chmod() [1] takes as the second parameter a bitwise or-ed combination of a series of values. If you look at chmod's man page (man 2 chmod on the shell) you can see the following values for the group id (I have OSX so the actual value may be different on your OS): #define S_IRWXG 070/* RWX mask for group */ #define S_IRGRP 040/* R for group */ #define S_IWGRP 020/* W for group */ #define S_IXGRP 010/* X for group */ So you just have to OR them to accomplish your goal. 1 - http://docs.python.org/lib/os-file-dir.html#l2h-2677 -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: chmod g+ Equivalent
milan_sanremo [EMAIL PROTECTED] wrote: I understand that for setting the standard rwx permissions, but how do these affect the ability to change the setgid bit? Under Solaris you cannot do it from the command line in absolute mode, so perhaps it is not possible in python I'm trying to get the equivalent of 'chmod g+' not something like 'chmod 755'. Sorry, I think I misunderstood the request. Isn't #define S_ISGID 0002000 what you're asking for? -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: get wikipedia source failed (urrlib2)
[EMAIL PROTECTED] wrote: This source works fine for other site. the problem is in wikipedia. is someone now any solution for this problem? Wikipedia, AFAIK, bans requests without a User Agent. http://www.voidspace.org.uk/python/articles/urllib2.shtml#headers -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: help with flexible decorators
james_027 [EMAIL PROTECTED] wrote: While the enhance decorator work with functions of 1 argument, how do I make it to work with more than one arguments. Using *args. Something like this: def enhance(f): def _new(*args): return f(*args) + 1 return _new @enhance def f(*args): return sum(args) In [22]: f(6) Out[22]: 7 In [23]: f(6, 4) Out[23]: 11 In [24]: f(6, 4, 10) Out[24]: 21 -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: simple string backspace question
[EMAIL PROTECTED] wrote: text=Hello\bworld print text HelloBSworld Should this character \b (backspace) in this text return this: Helloworld? [EMAIL PROTECTED] ~ % python Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type help, copyright, credits or license for more information. text=Hello\bworld print text Hellworld What system are u using? -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: simple string backspace question
[EMAIL PROTECTED] wrote: If you mean on operating system then unfortunately Windows XP. I don't know for sure but maybe it doesn't support all ASCII escapes codes. Why do you care about \b anyway :-) ? -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Detecting __future__ features
Steven D'Aprano [EMAIL PROTECTED] wrote: Is there any general mechanism? I'd just use the expected future feature and if the result is not what I expect (or Python raises any kind of exception, like using a keyword not present) I'd think I'm in the past :-) -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Copy List
Joe Riopel [EMAIL PROTECTED] wrote: I am pretty new to python but this works: list_one = [0,1,2,3,4,5,6,7,8,9] list_two = [i for i in list_one] print list_two [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] list_two = list_one[:] or list_two = list(list_one) are better :D -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: best SOAP module
Sells, Fred [EMAIL PROTECTED] wrote: I need to talk to a vendor side via SOAP, Googling is overwhelming and many hits seem to point to older attempts. Can someone tell me which SOAP module is recommended. I'm using Python 2.4. Try soaplib: http://trac.optio.webfactional.com/ -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic method
Bruno Desthuilliers [EMAIL PROTECTED] wrote: I agree that in general the solution explained by Alex and you is better. They are not better - they are correct. Another way is to use the 'types' module: In [1]: class T(object): ...: pass ...: In [2]: t = T() In [3]: import types In [5]: types.MethodType? Type: type Base Class: type 'type' String Form:type 'instancemethod' Namespace: Interactive Docstring: instancemethod(function, instance, class) Create an instance method object. In [10]: m = types.MethodType(lambda self: 3, t, T) In [11]: t.m = m In [12]: t.m() Out[12]: 3 -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Discover instance variables
Gabriel Genellina [EMAIL PROTECTED] wrote: The list keeps only the types explicitely enumerated. Other types are excluded, as well as names starting with _. Another criterion would be `not attr.startswith('_') and not callable(getattr(obj,attr))` Why not: In [1]: class Foo(object): ...: a = 3 ...: ...: In [2]: import inspect In [4]: inspect.getmembers(Foo()) Out[4]: [('__class__', class '__main__.Foo'), ('__delattr__', method-wrapper '__delattr__' of Foo object at 0x12bf350), ('__dict__', {}), ('__doc__', None), ('__getattribute__', method-wrapper '__getattribute__' of Foo object at 0x12bf350), ('__hash__', method-wrapper '__hash__' of Foo object at 0x12bf350), ('__init__', method-wrapper '__init__' of Foo object at 0x12bf350), ('__module__', '__main__'), ('__new__', built-in method __new__ of type object at 0x307860), ('__reduce__', built-in method __reduce__ of Foo object at 0x12bf350), ('__reduce_ex__', built-in method __reduce_ex__ of Foo object at 0x12bf350), ('__repr__', method-wrapper '__repr__' of Foo object at 0x12bf350), ('__setattr__', method-wrapper '__setattr__' of Foo object at 0x12bf350), ('__str__', method-wrapper '__str__' of Foo object at 0x12bf350), ('__weakref__', None), ('a', 3)] and then filter out __xyz__ methods? -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: __unicode__ method for exception object
Ben Finney [EMAIL PROTECTED] wrote: Your terminal has been detected as using the 'ascii' encoding, so while that's true no attempt to output non-ASCII characters will work. You'll need to change whatever settings are on your terminal emulator so that it is using an encoding (such as 'utf-8') which can display the characters you want. AFAIK that's not a terminal problem. I have a UTF-8 terminal and the problem is still there. -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with pickle
K Gaur [EMAIL PROTECTED] wrote: this is what the python interpreter returns on giving the basic command pickle.dump(x,f) where x is a tuple and f is a file object Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'pickle' is not defined kindly elucidate what's wrong You should import the module in the local namespace before using it: import pickle pickle.dump -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Timing a python program run
David [EMAIL PROTECTED] wrote: Is there some way to do this in python on a mac os x from the terminal window? Or whatever? You can use: % time script.py from the command line of the terminal -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: glob.glob standardization
billiejoex [EMAIL PROTECTED] wrote: Don't you think it would be more convenient for glob.glob to return file names only in any case, like os.listdir do? AFAIK it's a wanted behavior. The doc says: Notice how any leading components of the path are preserved. -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
[ANN] Pinder 0.6.0
Pinder http://dev.oluyede.org/pinder/ is a straightforward API to interface with Campfire http://www.campfirenow.com, the web chat application from 37Signals. The 0.6.0 version of Pinder has been released. Here what's new: - Campfire objects now have rooms() and rooms_names() methods to get the list of the associated room objects and the names of all the rooms - Campfire objects also have find_or_create_room_by_name(), an helper method which combine find_room_by_name() and create_room() - The whole library has been updated to httlibp2 0.3.0 - A proper user agent is sent during the requests - Room objects now have guest_access_enabled() to know if the guests can enter that room - The support for transcripts has been added throughout the library. See the changelog for details. You can install the latest release with: $ easy_install pinder or download it from here: http://dev.oluyede.org/download/pinder/ -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Prevent Modification of Script?
[EMAIL PROTECTED] wrote: Just throw out the .py files and let it run on the .pyc's alone. Which are very easily decompilable. :-) -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I get the content of a web site using http library
[EMAIL PROTECTED] wrote: http://www.python.org/doc/current/lib/module-urllib2.html Look into urlopen's data parameter. I add also this tutorial to the plate: http://www.voidspace.org.uk/python/articles/urllib2.shtml -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about extending tuple
abcd [EMAIL PROTECTED] wrote: I wanted to extend tuple but ran into a problem. Here is what I thought would work I think you should take a look at this to do it properly from the Python devs: http://svn.python.org/view/python/trunk/Lib/collections.py Look for NamedTuple -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: ZSI, SOAP and .NET web services - problem
Jaroslaw Zabiello [EMAIL PROTECTED] wrote: Why nobody wants to add SOAP to standard Python library? XML-RPC was added and it works without any problems. I think because SOAP is kinda crappy :-) Did you try soaplib? http://trac.optio.webfactional.com/ I've never used it (nor SOAP in a while) but seems promising -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: read a web page using python
[EMAIL PROTECTED] wrote: Kindly, could you someone tell me how to read a page(any web site) using Python, what method to be used ? import urllib2 res = urllib2.urlopen(url) page = res.read() See: http://www.voidspace.org.uk/python/articles/urllib2.shtml -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
ANN: pinder 0.5.0
Pinder is a straightforward API to interface with Campfire http:// www.campfirenow.com, the web chat application from 37Signals. Pinder allows you to create rooms, delete them, speak from a remote client and more. For example: room = campfire.find_room_by_name('Jonz Room') print room.users() set([u'Alice']) or print campfire.users() set([u'Alice', u'Bob']) which gets the list of the users talking in each room of the subdomain. room.speak(Foobar) will send the message to the chat room so you can speak too. There's more like creating and deleting rooms, toggling guest access, locking the room etc. See the usage documentation http://dev.oluyede.org/pinder/doc.html and the API documentation http://dev.oluyede.org/pinder/api/ for details. You can install the latest release with: $ easy_install pinder or download from here: http://dev.oluyede.org/download/pinder/ This is the first public release. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Sending Dictionary via Network
Chris Mellon [EMAIL PROTECTED] wrote: I would recommend against using pickle if you're going to push it over a network - there are signifigant dangers in unpickling anything untrusted. I confirm: http://jcalderone.livejournal.com/15864.html -- Lawrence - http://www.oluyede.org/blog http://www.neropercaso.it Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Where I can find
[EMAIL PROTECTED] wrote: Where I can find this files(modules): fcntl,FCNTL,tty,termios, TERMIOS import fcntl import tty import termios for start :-) -- Lawrence - http://www.oluyede.org/blog http://www.neropercaso.it Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: HOST - Assembla Inc. Breakout - Copyright Violation by Mr. Andy Singleton
Ilias Lazaridis [EMAIL PROTECTED] wrote: and once more: this topic _is_ appropriate for a python / ruby / java crosspost. really very important (if you don't look to much at the subject but the message contents). I really don't understand why your public announcement should be in topic in this newsgroup. -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: What value should be passed to make a function use the default argument value?
LaundroMat [EMAIL PROTECTED] wrote: What value do I have to pass to f() if I want it to evaluate var to 1? I know that f() will return 2, but what if I absolutely want to pass a value to f()? None doesn't seem to work.. I don't know if I understand correctly here but: def f(v=1): return v * 2 f() returns 2 f(1) returns 2 too v = 1 f(v) returns 2 too What do you mean? -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes question about call by reference
Oliver Andrich [EMAIL PROTECTED] wrote: - ExceptionType is an enum - MagickWand is somewhat strange, but so far it works fine without any type mangling. How would I wrap this thing using ctypes? Can anybody help me with that? First thing first: you have to identify how ExceptionType and MagickWand are composed of. Then you can start wrapping them following the instructions in the tutorial: http://docs.python.org/lib/ctypes-ctypes-tutorial.html -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes question about call by reference
Oliver Andrich [EMAIL PROTECTED] wrote: Well, what I learned so far from the documentation, which I already have read more then once today, is that there is no example for an enum in this situation. But looking at pygame-sdl and another project, it looks like the enum is just an c_int or c_long. The documentation explains how to build an enum to pass to a function: http://docs.python.org/lib/ctypes-structures-unions.html See the first sentence. class ExceptionType(Union): _fields_ = [list_of_tuples] Is it at all possbile to use a struct without defining it with ctypes? If you want to use it you have to define it somewhere... Is it okay, to just use the int which is returned by default? Most of my library works with that configuration, so I thought it is working. I see your functions returns a char * so I don't understand what are you saying here... Based on this, can you give me some more hints? It's not really clear :-) -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie IronPython compiled scripts speed question
dtlog [EMAIL PROTECTED] wrote: I searched the faqs at python.org and didn't find an answer: does using IronPython, instead of CPython, and compiling the scripts into native windows executables (I heard IronPython can do that) result in faster execution times? I don't know what you heard but IronPython generates IL code which happens to be the bytecode of the CLR (the runtime of .NET). So you are not generating native stuff but a PE executable wrapping the .NET stuff in it. See: http://en.wikipedia.org/wiki/Portable_Executable#.NET.2C_metadata.2C_and _the_PE_format It seems IronPython being faster than CPython 2.4 in some tests but I can't say anything about that because I haven't seen that tests :-) -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: what's new missing
David Isaac [EMAIL PROTECTED] wrote: What's New document for Python 2.5? http://docs.python.org/dev/whatsnew/whatsnew25.html pretends to hold it, but the links are corrupt. It's without /dev/ -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: new string method in 2.5 (partition)
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: What's the difference between this and string.split? ('http://www.python.org').partition('://') ('http', '://', 'www.python.org') ('http://www.python.org').split('://') ['http', 'www.python.org'] -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get a Fix to an Abandoned Project?
Gregory Piñero [EMAIL PROTECTED] wrote: Otherwise any other advice is welcome. Should I just post the code somewhere else, etc? Maybe you can fork and maintain it somewhere else... -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Webbrowser written totally in Python
Franz Steinhaeusler [EMAIL PROTECTED] wrote: is there any (GUI) webbrowser written completly in Python? AFAIK Grail is the only attempt but it's _very_ old: http://grail.sourceforge.net/ Made in Python, Tkinter and supports HTML 2.0 (3.2 partially) -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a python IDE
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Any suggestions? Maybe BlackAdder http://www.thekompany.com/products/blackadder/ -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not event-driven packages in other than the main thread?
Tor Erik [EMAIL PROTECTED] wrote: I've developed an application were I've used Tkinter for the GUI. When I ran the GUI in another thread than the main, it kept locking up. That's because Tkinter is not thread safe AFAIK. I experienced similar problems with Twisted. Neither Twisted is thread-aware. It uses thread for a couple of things (twisted.row and address resolution). You can call stuff in a separate thread with deferToThread or callInThread but avoid threads is best. But could anyone tell me why running these in a thread other than the main one doesn't work? Because neither Twisted nor Tkinter are meant to work with threads. -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not event-driven packages in other than the main thread?
Tor Erik [EMAIL PROTECTED] wrote: If you have two event-based frameworks, both needing to run in the main thread, such as Tkinter and Twisted, you have a problem Twisted supports Tkinter: http://twistedmatrix.com/projects/core/documentation/howto/choosing-reac tor.html#auto14 It's better to use GUI with a real reactor available like GTK2 anyway... -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not event-driven packages in other than the main thread?
Bjoern Schliessmann [EMAIL PROTECTED] wrote: What's not real about Tkinter's? It's not a custom reactor as GTK's AFAIK -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: How to build extensions on Windows?
Martin v. Löwis [EMAIL PROTECTED] wrote: That, of course, assumes that there is a VS 2007 release sufficiently before Python 2.6. I just spoke with an MVP for .NET (so nothing official obviously) and he told me the next VS version will ship after Windows Vista for sure and that (he mentioned the actual alpha status of the available components) will be likely in the second half of the year or maybe later. Anyway after the release of Vista we will all know something more I guess. HTH -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: python threading
daniel [EMAIL PROTECTED] wrote: can someone give me a good threading tutorial http://awaretek.com/tutorials.html#thread and http://www.google.com/search?q=python+threading+tutorial -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with ctypes pointer return values
[EMAIL PROTECTED] wrote: Does anyone have a good idea how I should define recordList so that I can retrieve the record pointers? POINTER(POINTER(c_void)) ? Maybe I misunderstood tough... -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: How to build extensions on Windows?
Kevin D. Smith [EMAIL PROTECTED] wrote: Then there is Mike Fletcher's web page (http://www.vrplumber.com/programming/mstoolkit/) that describes in detail how to build extensions, but most of the links to external software are no longer valid. I think it's safe to say that I am completely lost, as there appears to be no authoritative, up-to-date description on how to make this work. I managed to set up a compilation toolchain in Windows following that tutorial so what's your problem? I installed MS .NET 1.1 and its SDK, the Platform SDK for Windows 2003 sever and the mstoolkit (you have to borrow it from somewhere because it's not available anymore) Then I hacked distutils and all worked well. The only issue is to find the MS Toolkit 2003... -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] IronPython 1.0 released today!
Felipe Almeida Lessa [EMAIL PROTECTED] wrote: Does IronPython runs Twisted? I really don't think so. They don't have many needed modules, like select :-) -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: How to build extensions on Windows?
Kevin D. Smith [EMAIL PROTECTED] wrote: So in other words, what you're saying is that the only issue I have left is the exact issue that I described in my initial post that you claimed isn't a problem... Great! I guess I'l get right down to work compiling that extension now. What I mean is that you have to find a way to get the toolkit. I don't think MS will sue you if you borrow the compiler from a friend or download it. Otherwise you can try with MingW I guess... -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: How to build extensions on Windows?
Jason [EMAIL PROTECTED] wrote: I don't know about MinGW, but you can get the Microsoft compilers by installing Visual C++ 2005 Express. I'm guessing the old toolkit is deprecated. While you must register each Visual Studio Express module that you download, I don't think the actual command-line tools are encumbered. Why not try it out and let us know how it goes? (Visual Studio 2005 Express: http://msdn.microsoft.com/vstudio/express/) Because you can't use it to distribute extensions. Python is compiled against the 2003 version and distutils will simply don't let you compile with the 2005 version. If you manage to hack distutils to use the 2005 anyway it won't work for sure outside your home box. -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] IronPython 1.0 released today!
Duncan Booth [EMAIL PROTECTED] wrote: So? IronPython has a select module although it doesn't seem to be complete yet. The IronPython mailing list has discussions about getting CherryPy to run, and it sounds as though it isn't quite there yet, but it is getting there. I don't think my answer is wrong. He asked if Twisted runs on IronPython and as a matter of fact it doesn't. Everything can happen in the future :-) -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
Sandra-24 [EMAIL PROTECTED] wrote: Oh I'm aware of that, but it's not what I'm looking for. Mod_mono just lets you run ASP.NET on Apache. I'd much rather use Python :) Now if there was a way to run IronPython on Apache I'd be interested. Take a look here: http://lists.ironpython.com/pipermail/users-ironpython.com/2006-March/00 2049.html and this thread: http://www.mail-archive.com/users@lists.ironpython.com/msg01826.html -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
Lawrence Oluyede [EMAIL PROTECTED] wrote: Take a look here: http://lists.ironpython.com/pipermail/users-ironpython.com/2006-March/00 2049.html and this thread: http://www.mail-archive.com/users@lists.ironpython.com/msg01826.html Also this: http://www.codeproject.com/useritems/ipaspnet.asp Google is you friend! :-) -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Pros/Cons of Turbogears/Rails?
Christophe [EMAIL PROTECTED] wrote: Google doesn't find YARM and so, YARM does not exist. Care to provide an URL or something? it's YARV - http://www.atdot.net/yarv/ -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie question about import tools
[EMAIL PROTECTED] wrote: do i need to download tools.pyc ? Python doesn't have any tools module builtin. So, what tool is? -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: opposite of import
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I am new to python. I wanted to know if there is an opposite of import What do you mean? What are you trying to accomplish? -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: New Martelli Nutshell Out
BartlebyScrivener [EMAIL PROTECTED] wrote: My preordered copy of Python In A Nutshell just arrived from Amazon. http://tinyurl.com/pkczm Looking forward. Me too :-) Mine has been shipped yesterday. -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: EuroPython 2006 and Py3.0
Antoon Pardon [EMAIL PROTECTED] wrote: These are just some ideas. Whether they fit into python or not I will leave to the developers. I'm not a Python pro. but: 1) Literal slices, in a sense we already have these, but they are limited to indexing. You can't do something like fun(::). May be this means the notation used now has to be adapted. I don't see the use case for this. 2) Iterable slices. Allow (provided the slice notation stays:) for i in (1:10): ... to do the same as: for i in xrange(1,10): This will allow to get rid of both range and xrange. Xrange is totally unnecessary and range(a,b) becomes list(a:b). -1. First: you have to introduce new syntax for an old thing. Second: you overload the meaning of slicing and the slice operator and so on. range is perfectly integrated and the right tool for the job. There's no need to introduce new syntax to iterate over a range of integers. 4) Introduce Top and Bottom objects, which will allways compare greater/smaller to other objects. Make them the default values for the start and stop values of slices. 5) Give slices a and | operator. 7) Give slices the possibility to include the stop value. My first idea here was that the notation of slices was adapted, so that what is a:b now would become a:|b. A slice to include the b would then be a::b. You could even have a slice that didn't include the a but included the b like: a|:b Now I expect a lot of resitance here, so it this seems not feasable, just drop it. 6) Is this is all asked too much, make slice at least subclassable. Why do you need power slices? -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: EuroPython 2006 and Py3.0
Antoon Pardon [EMAIL PROTECTED] wrote: I have a tree class, a tree acts like a dictionary, but when you iterate over it, it always iterates over the keys in order. This makes it usefull to iterate over a slice. So it would be usefull if methods like keys, values and items could take a slice as an argument and use the same notation for it. Something like for k, v in t.items('a':'b'): Which would iterate over all items where the key starts with an 'a'. I keep thinking that means changing the meaning of slice -1. First: you have to introduce new syntax for an old thing. That syntax already exists, it just is only available as an index. Slicing and indexing is inside square brackets. (start:stop) seems confusing to me. And I seriously doubt that Guido or someone on his behalf will go through introducing another syntax for something that can be already done in one way. I came to Python because of it's clean syntax and I've always tought one good way to do one thing is better than Perlish style. That's why I don't like powering up slice objects to do that. Range as it is, is going to disappear. Last time I read the python 3000 Pep range would get the functionality of xrange and xrange would disappear, and those who want a list will have to do: list(range(a,b)) Yep but generators are better to iterate. list(range_object) is less common than for i in range_object AFAIK Need is such a strong word. In the end we don't need python, but it seems very usefull to have it around. I understand that should this be introduced it could make people uneasy, but I also think it could be very usefull. I'm not the person in charge to make decisions about Python syntax, power and limitations but I really don't see a useful use case to have a slice++. Even decorators (that few people really understand) have a lot of use cases more than slice++ Because it would have made things a lot of easier for me in a number of cases. I have a table class that is like a list but can start at any index, it sure would have been easier to write with some of the possibilities above. I though to just write my own slice class, but slice is not subclassable, and when I just wrote my own from scratch, with a start, stop and step attribute I got an error that it wasn't an integer so couldn't be used as an index. So much for duck taping. I understand. So maybe asking for subclassable slices is better :-) -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: EuroPython 2006 and Py3.0
A.M. Kuchling [EMAIL PROTECTED] wrote: If Python 3000 turns into a let's-try-all-sorts-of-goofy-new-ideas language, at least some of those ideas will turn out to have been mistakes, and then we'll need a Python 3000++ to clean things up. And I also think we will lose some developers in the community. Python is good because is flexible and it's tight to the need of people who write code for passion, work and educational purposes (that's another meaning of multiple purposes language). If Python turns to be only an educational language... it will definitely fail. -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Accessors in Python (getters and setters)
mystilleef [EMAIL PROTECTED] wrote: What is the Pythonic way of implementing getters and setters. Using public members and turning them into properties when needed I've heard people say the use of accessors is not Pythonic. But why? Because there's no need to have them everywhere But now my code base is expanding and I'm beginning to appreciate the wisdom behind them. I welcome example code and illustrations. Search for python property -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a Python __LINE__ ?
Rolf Wester [EMAIL PROTECTED] wrote: is there a Python aquivalent to the C __LINE__? I found this in the archives: http://groups.google.it/group/comp.lang.python/browse_thread/thread/315e f9451067a320/87785edf569c1e96?q=current+linernum=2#87785edf569c1e96 -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Controlling Windows Media Player from Python
Jeffrey Barish [EMAIL PROTECTED] wrote: Is there a way to interact with Windows Media Player from Python? I would like to be able to do things like tell WMP to play a given sound file or to ask WMP for metadata about a sound file. Take a look at pywinauto, I attended the today talk at EP2006 and seemed really cool. http://pywinauto.pbwiki.com -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: mmap as a sequence behavior
Scott David Daniels [EMAIL PROTECTED] wrote: That is sequence behavior. The convention of -1 for last, -2 for second-to-last, ... is done before it gets to your C code. I suspect if you don't define a __len__ method, you'd suppress this. I defined a __len__ method but I get the index plain without any kind of conversion before entering the method -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: mmap as a sequence behavior
Lawrence Oluyede [EMAIL PROTECTED] wrote: What am I missing from the C API? Found. I edit abstract.c placing some printf here and there and discovered PyObject_GetItem is always called and in turn it call PySequence_GetItem so is there my index is translated. -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
mmap as a sequence behavior
While wrapping mmap indexing/sequence emulation I noticed something strange. The source code of this oddity is: static PyObject * mmap_item(mmap_object *self, Py_ssize_t i) { CHECK_VALID(NULL); if (i 0 || (size_t)i = self-size) { PyErr_SetString(PyExc_IndexError, mmap index out of range); return NULL; } return PyString_FromStringAndSize(self-data + i, 1); } located in mmapmodule.c What's got my attention was the fact that passing -1 from Python does not trigger the exception but is changed to the last positive and valid index. Let's make an example: import mmap f = open(foo, w+) f.write(foobar) f.flush() m = mmap.mmap(f.fileno(), 6) print m[-1] # == 'f' I expect this raise IndexError as reading the C source code but it behaves exactly like sequence types in Python. That's fair to me but I don't get *where* my index is translated. If I print the 'i' variable in the C source code before the if statement I get len(ourmap) - 1 instead of -1 What am I missing from the C API? -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on intel osx
John Lockwood [EMAIL PROTECTED] wrote: Can someone please suggest the most suitable python for mac osx 10.4.6 Finding the right installs doesn't seem quite as cut and dried as it is for linux or windows. open google, type python osx and go to the _second_ result. It's http://pythonmac.org/packages/ I'm also looking for numeric and pyopengl. I compiled Numeric manually and it worked fine. Dunno about pyopengl -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it possible to split a class definition?
[EMAIL PROTECTED] wrote: Is it possible to split a Class definition over two or more text files? (if so, how:) There's no partial types like in .NET 2.0 but since Python is dynamic you can add members at runtime :-) -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Why list.sort() don't return the list reference instead of None?
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: I want to ask why the designer of Python do so? I'm not a Python core developer nor a designer but I've always known that sort() is a in-place sort and since the list is a mutable object it mutates the list sending the sort() message. If you want to get back a sorted iterable use... sorted :) L = [3, 1, 2] ls = sorted(L) now ls is your list, sorted. -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Why list.sort() don't return the list reference instead of None?
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: However, I wonder why L.sort() don't return the reference L, the performance of return L and None may be the same. It's not the same. sort() does not return anything. Why? I've just explained to you and so the others: by default operations on mutable objects are in place. s = abc s.upper() does return another string. String are immutable references. -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's regular expression?
Davy [EMAIL PROTECTED] writes: Does Python support robust regular expression like Perl? Yep, Python regular expression is robust. Have a look at the Regex Howto: http://www.amk.ca/python/howto/regex/ and the re module: http://docs.python.org/lib/module-re.html -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Upgrading and modules
Brian Elmegaard [EMAIL PROTECTED] writes: I don't it includes every possible module, e.g., py2exe, ctypes, mysqldb, wxpython... Right but since Python doesn't have a full-integrated central packaging (despite the ongoing Pypi project and Eby's efforts in setuptools) you have to do it manually :) How many modules do you really use? It's a matter of minutes. -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: Should I learn Python instead?
fyleow [EMAIL PROTECTED] writes: I'm a student/hobbyist programmer interested in creating a web project. I'm a student too and I've done a little Python web related stuff long ago. It's nothing too complicated, I would like to get data from an RSS feed and store that into a database. I want my website to get the information from the database and display parts of it depending on the criteria I set. That's a really easy thing to do. You're lucky because thanks to Mark Pilgrim we have one of the best RSS/Atom parsing libraries out there: http://feedparser.org/ It's quite simple: 1 - you parse the feed 2 - you take the data 3 - you display them in your html page with one of the python frameworks available. I just finished an OO programming class in Java and I thought it would be a good idea to do this in C# since ASP.NET makes web applications easier than using Java (that's what I've heard anyway). It's quite right. ASP.NET is easier than JSP and J2EE stuff but Python is better to me :) I thought it would be easy to pick up since the language syntax is very similar but I'm getting overwhelmed by the massive class library. MSDN docs are very good and thorough but the language just seems a little unwieldy and too verbose. Yeah they like in that way. A 4+ class library and gigatons of documents. All is verbose in their static world: documents, books, languages :( This is how to access an RSS feed and create an XML document to manipulate it. I know the author of the RSS.NET library and I used it in the past, it can save you some machinery. But why get a bad language with a good library instead of a wonderful library and a very good language :) ? Is Python easier than C#? IMHO yes. Can someone show how to access an XML document on the web and have it ready to be manipulated for comparison? Any other advice for a newbie? Start with the examples on the feedparser homepage. Then choose a framework (Turbogears? CherryPy?) and then it's a matter of _minutes_ to have a HTML page filled with your data. -- Lawrence - http://www.oluyede.org/blog Nothing is more dangerous than an idea if it's the only one you have - E. A. Chartier -- http://mail.python.org/mailman/listinfo/python-list
Re: white space in expressions and argument lists
John Salerno [EMAIL PROTECTED] writes: 1 + 2 or 1+2 func(1,2) or func(1, 2) I prefer and use 1 + 2 and func(1, 2) I don't do whitespaces only in argument defaults like func(foo=baz) -- Lawrence - http://www.oluyede.org/blog Anyone can freely use whatever he wants but the light at the end of the tunnel for most of his problems is Python -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin: any way to delete all objects without exiting and without doing it with del?
[EMAIL PROTECTED] writes: In PythonWin, is there any way to bulk-delete all objects without using del object for each, and without having to exit out of PythonWin? PythonWin is just an IDE. For what reason you have to delete all objects by yourself? Garbage collector is there for that :) -- Lawrence - http://www.oluyede.org/blog Anyone can freely use whatever he wants but the light at the end of the tunnel for most of his problems is Python -- http://mail.python.org/mailman/listinfo/python-list
Re: SyntaxError: can't assign to a function call
Fuzzyman [EMAIL PROTECTED] writes: f() += [4] SyntaxError: can't assign to function call It's obvious that that line gives you a syntax error. += is the increment operator overloaded for strings and lists and so on. It changes the lhs in place appending the rhs. In this case the rhs is a function call so... how the compiler knows how to assign to a function call? Do the things easily: - x = f() - x += [4] :) -- Lawrence - http://www.oluyede.org/blog Anyone can freely use whatever he wants but the light at the end of the tunnel for most of his problems is Python -- http://mail.python.org/mailman/listinfo/python-list
Re: PyAtom, a Python module for creating Atom syndication feeds
Steve R. Hastings [EMAIL PROTECTED] writes: I intend to donate this to the Python Software Foundation, so I have released it under the terms of the Academic Free License 2.1. You can download it from here: http://www.blarg.net/~steveha/pyatom.tar.gz The file includes a readme.txt file with a few notes, and pyatom.py. Very interesting, I was looking forward to something like that in the past and found atomixlib but it has heavy dependencies. Yours seems nicer. Anyway, you don't follow PEP 8 guidelines and AFAIK a module must be widespread and used by the community before can be accepted in the Python core. The same happened with Lundh's ElementTree Good job :) -- Lawrence - http://www.oluyede.org/blog Anyone can freely use whatever he wants but the light at the end of the tunnel for most of his problems is Python -- http://mail.python.org/mailman/listinfo/python-list