Re: Unicode literals and byte string interpretation.

2011-10-28 Thread Steven D'Aprano
On Thu, 27 Oct 2011 20:05:13 -0700, Fletcher Johnson wrote: > If I create a new Unicode object u'\x82\xb1\x82\xea\x82\xcd' how does > this creation process interpret the bytes in the byte string? It doesn't, because there is no byte-string. You have created a Unicode object from a literal strin

Re: Need Windows user / developer to help with Pynguin

2011-10-28 Thread Lee Harr
>> I started a wiki page >> here:  >> >> http://code.google.com/p/pynguin/wiki/InstallingPynguinOnWindows >> >> but I can't even test if

Re: Assigning generator expressions to ctype arrays

2011-10-28 Thread Steven D'Aprano
On Thu, 27 Oct 2011 17:09:34 -0700, Patrick Maupin wrote: > On Oct 27, 5:31 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> From the outside, you can't tell how big a generator expression is. It >> has no length: > > I understand that. > >> Since the array object has no way of te

Re: Dynamically creating properties?

2011-10-28 Thread Steven D'Aprano
On Thu, 27 Oct 2011 16:00:57 -0700, DevPlayer wrote: > def isvalid_named_reference( astring ): > # "varible name" is really a named_reference > # import string # would be cleaner I don't understand the comment about "variable name". > valid_first_char = > '_abcdefghijklmnopqrstuvw

Re: __dict__ attribute for built-in types

2011-10-28 Thread Steven D'Aprano
On Fri, 28 Oct 2011 00:52:40 +0200, candide wrote: > Le 28/10/2011 00:19, Steven D'Aprano a écrit : >> >> What, you think it goes against the laws of physics that nobody thought >> to mention it in the docs? > > > No but I'm expecting from Python documentation to mention the laws of > Python ...

Re: Assigning generator expressions to ctype arrays

2011-10-28 Thread Terry Reedy
On 10/28/2011 3:21 AM, Steven D'Aprano wrote: If the slice has too few elements, you've just blown away the entire iterator for no good reason. If the slice is the right length, but the iterator doesn't next raise StopIteration, you've just thrown away one perfectly good value. Hope it wasn't

Re: spawnl issues with Win 7 access rights

2011-10-28 Thread Tim Golden
On 27/10/2011 20:53, Terry Reedy wrote: On 10/27/2011 6:36 AM, Tim Golden wrote: On 27/10/2011 11:27, Propad wrote: the suggestion to add the optional second parameter fixed the problem, spawnl now works on the Win 7 computer I'm responsible for (with Python 2.2). So the suggested cause seems t

Re: __dict__ attribute for built-in types

2011-10-28 Thread Hrvoje Niksic
candide writes: > Le 28/10/2011 00:57, Hrvoje Niksic a écrit : > >> was used at class definition time to suppress it. Built-in and >> extension types can choose whether to implement __dict__. >> > > Is it possible in the CPython implementation to write something like this : > > "foo".bar = 42 >

Re: Entre local et global

2011-10-28 Thread Laurent
Le 28/10/2011 10:43, ll.snark a écrit : On 27 oct, 17:06, Laurent Claessens wrote: > J'aimerais donc pouvoir indiquer dans fonca, que la variable lst est > celle définie dans fonc1. > Je ne veux pas d'une variable locale à fonca, ni une variable globale > à tout mon fichier (cf exemple

Re: __dict__ attribute for built-in types

2011-10-28 Thread candide
Le 28/10/2011 05:02, Patrick Maupin a écrit : You can easily do that by subclassing a string: class AnnotatedStr(str): pass x = AnnotatedStr('Node1') x.title = 'Title for node 1' Less or more what I did. But requires to transport the string graph structure to the AnnotatedStr one.

Re: __dict__ attribute for built-in types

2011-10-28 Thread candide
Le 28/10/2011 10:01, Steven D'Aprano a écrit : didn't think of it. This is hardly a surprise. Wanting to add arbitrary attributes to built-ins is not exactly an everyday occurrence. Depends. Experimented programmers don't even think of it. But less advanced programmers can consider of it.

Re: __dict__ attribute for built-in types

2011-10-28 Thread candide
Le 28/10/2011 11:08, Hrvoje Niksic a écrit : longer be allowed for the interpreter to transparently cache them. The same goes for integers and other immutable built-in objects. On the other hand, immutability and optimization don't explain the whole thing because you can't do something like

Re: Entre local et global

2011-10-28 Thread Laurent Claessens
Woops. This was aimed to the french speaking python's usenet. Sorry. Laurent Le 28/10/2011 11:29, Laurent a écrit : Le 28/10/2011 10:43, ll.snark a écrit : On 27 oct, 17:06, Laurent Claessens wrote: > J'aimerais donc pouvoir indiquer dans fonca, que la variable lst est > celle défi

Re: __dict__ attribute for built-in types

2011-10-28 Thread Christian Heimes
Am 28.10.2011 10:01, schrieb Steven D'Aprano: hasattr(int, '__dict__') # Does the int class/type have a __dict__? > True hasattr(42, '__dict__') # Does the int instance have a __dict__? > False Also __dict__ doesn't have to be an instance of __dict__. Builtin types usually have a dictp

Is Python in the browser a dead-end ?

2011-10-28 Thread Amirouche Boubekki
Héllo, There was a thread recently about the missed opportunity for Python to be a language that could replace Javascript in the browser. They are several attempts at doing something in this spirit here are the ones I'm aware of: - pyjamas aka. pyjs it is to Python what GWT is to Java : http://p

Re: Is Python in the browser a dead-end ?

2011-10-28 Thread Billy Earney
I believe that python maybe had missed an opportunity to get in early and be able to take over a large market share from javascript. But that doesn't mean python is dead in the browser, it just means it will have more competition if it wants to replace javascript for Rich Internet Applications. t

ANN: python-ldap 2.4.4

2011-10-28 Thread Michael Ströder
Find a new release of python-ldap: http://pypi.python.org/pypi/python-ldap/2.4.4 python-ldap provides an object-oriented API to access LDAP directory servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for that purpose. Additionally it contains modules for other LDAP-related stu

Re: __dict__ attribute for built-in types

2011-10-28 Thread Peter Pearson
On Fri, 28 Oct 2011 00:52:40 +0200, candide wrote: [snip] > hasattr(42, '__dict__') >> False [snip] > > Let'have a try : > > >>> hasattr(43, '__dict__') > False > >>> > > so we have proved by induction that no integer instance has a > dictionnary attribute ;) You left out an important step i

getting columns attributes in declarative style with sqlalchemy

2011-10-28 Thread Gabriele
Hi, I'm tryed to write my first application using SqlAlchemy. I'm using declarative style. I need to get the attributes of the columns of my table. This is an example of my very simple model-class: class Country(base): __tablename__ = "bookings_countries" id = sqlalchemy.Column(sqlalc

Re: Forking simplejson

2011-10-28 Thread Nathan Rice
Just a random note, I actually set about the task of re-implementing a json encoder which can be subclassed, is highly extensible, and uses (mostly) sane coding techniques (those of you who've looked at simplejson's code will know why this is a good thing). So far preliminary tests show the json o

How to mix-in __getattr__ after the fact?

2011-10-28 Thread dhyams
Python 2.7.2 I'm having trouble in a situation where I need to mix-in the functionality of __getattr__ after the object has already been created. Here is a small sample script of the situation: =snip import types class Cow(object): pass # this __getattr__ works as advertised.

Re: Assigning generator expressions to ctype arrays

2011-10-28 Thread Patrick Maupin
On Oct 27, 10:23 pm, Terry Reedy wrote: > I do not think everyone else should suffer substantial increase in space > and run time to avoid surprising you. What substantial increase? There's already a check that winds up raising an exception. Just make it empty an iterator instead. > > It vio

Fast recursive generators?

2011-10-28 Thread Michael McGlothlin
I'm trying to generate a list of values where each value is dependent on the previous value in the list and this bit of code needs to be repeatedly so I'd like it to be fast. It doesn't seem that comprehensions will work as each pass needs to take the result of the previous pass as it's argument. m

Re: How to mix-in __getattr__ after the fact?

2011-10-28 Thread Jerry Hill
On Fri, Oct 28, 2011 at 1:34 PM, dhyams wrote: > If I call __getattr__ directly, as in bessie.__getattr__('foo'), it > works as it should obviously; so the method is bound and ready to be > called.  But Python does not seem to want to call __getattr__ > appropriately if I mix it in after the objec

Re: How to mix-in __getattr__ after the fact?

2011-10-28 Thread Ethan Furman
dhyams wrote: Python 2.7.2 I'm having trouble in a situation where I need to mix-in the functionality of __getattr__ after the object has already been created. Here is a small sample script of the situation: =snip import types class Cow(object): pass # this __getattr__ works

Re: Assigning generator expressions to ctype arrays

2011-10-28 Thread Terry Reedy
On 10/28/2011 2:05 PM, Patrick Maupin wrote: On Oct 27, 10:23 pm, Terry Reedy wrote: I do not think everyone else should suffer substantial increase in space and run time to avoid surprising you. What substantial increase? of time and space, as I said, for the temporary array that I think

Re: Fast recursive generators?

2011-10-28 Thread Terry Reedy
On 10/28/2011 2:10 PM, Michael McGlothlin wrote: I'm trying to generate a list of values Better to think of a sequence of values, whether materialized as a 'list' or not. where each value is dependent on the previous value in the list and this bit of code needs to be repeatedly so I'd like

save tuple of simple data types to disk (low memory foot print)

2011-10-28 Thread Gelonida N
Hi, I would like to save many dicts with a fixed amount of keys tuples to a file in a memory efficient manner (no random, but only sequential access is required) As the keys are the same for each entry I considered converting them to tuples. The tuples contain only strings, ints (long ints) an

Re: Forking simplejson

2011-10-28 Thread Terry Reedy
On 10/28/2011 1:20 PM, Nathan Rice wrote: Just a random note, I actually set about the task of re-implementing a json encoder which can be subclassed, is highly extensible, and uses (mostly) sane coding techniques (those of you who've looked at simplejson's code will know why this is a good thing

Re: Assigning generator expressions to ctype arrays

2011-10-28 Thread Patrick Maupin
On Oct 28, 3:19 am, Terry Reedy wrote: > On 10/28/2011 3:21 AM, Steven D'Aprano wrote: > > > If the slice has too few elements, you've just blown away the entire > > iterator for no good reason. > > If the slice is the right length, but the iterator doesn't next raise > > StopIteration, you've jus

Re: Forking simplejson

2011-10-28 Thread Nathan Rice
I've found that in a lot of cases getting a patch submitted is only half about good engineering. The other half is politics. I like one of those things, I don't like the other, and I don't want to take time out of my coding schedule to write something if in the end a reviewer shoots down my patch

Re: save tuple of simple data types to disk (low memory foot print)

2011-10-28 Thread Roy Smith
In article , Gelonida N wrote: > I would like to save many dicts with a fixed amount of keys > tuples to a file in a memory efficient manner (no random, but only > sequential access is required) There's two possible scenarios here. One, which you seem to be exploring, is to carefully study y

Re: Assigning generator expressions to ctype arrays

2011-10-28 Thread Patrick Maupin
On Oct 28, 4:51 pm, Patrick Maupin wrote: > On Oct 28, 3:19 am, Terry Reedy wrote: > > > On 10/28/2011 3:21 AM, Steven D'Aprano wrote: > > > > If the slice has too few elements, you've just blown away the entire > > > iterator for no good reason. > > > If the slice is the right length, but the it

Re: Fast recursive generators?

2011-10-28 Thread Michael McGlothlin
>> I'm trying to generate a list of values > > Better to think of a sequence of values, whether materialized as a 'list' or > not. The final value will actually be a string but it seems it is usually faster to join a list of strings than to concat them one by one. >> where each value is dependent

Re: save tuple of simple data types to disk (low memory foot print)

2011-10-28 Thread Steven D'Aprano
On Fri, 28 Oct 2011 22:47:42 +0200, Gelonida N wrote: > Hi, > > I would like to save many dicts with a fixed amount of keys tuples to a > file in a memory efficient manner (no random, but only sequential > access is required) What do you call "many"? Fifty? A thousand? A thousand million? How m

Re: Assigning generator expressions to ctype arrays

2011-10-28 Thread Steven D'Aprano
On Fri, 28 Oct 2011 16:27:37 -0700, Patrick Maupin wrote: > And, BTW, the example you give of, e.g. > > a,b,c = (some generator expression) > > ALREADY LOSES DATA if the iterator isn't the right size and it raises an > exception. Yes. What's your point? This fact doesn't support your proposal i

Re: Need Windows user / developer to help with Pynguin

2011-10-28 Thread Andrew Berg
On 10/27/2011 5:36 PM, Lee Harr wrote: > What message do you get when trying to download? It said something like "You're trying to download from a forbidden country. That's all we know." Anyway, I was able to get the files. Once everything is set up, it seems to work. I haven't done any serious te

Re: Assigning generator expressions to ctype arrays

2011-10-28 Thread Patrick Maupin
On Oct 28, 8:01 pm, Steven D'Aprano > > ALREADY LOSES DATA if the iterator isn't the right size and it raises an > > exception. > > Yes. What's your point? This fact doesn't support your proposal in the > slightest. You earlier made the argument that "If the slice has too few elements, you've just

Re: How to mix-in __getattr__ after the fact?

2011-10-28 Thread Lie Ryan
On 10/29/2011 05:20 AM, Ethan Furman wrote: Python only looks up __xxx__ methods in new-style classes on the class itself, not on the instances. So this works: 8< class Cow(object): pass def attrgetter(self, a): print "CAUGHT: At

Re: Fast recursive generators?

2011-10-28 Thread Terry Reedy
On 10/28/2011 8:49 PM, Michael McGlothlin wrote: Better to think of a sequence of values, whether materialized as a 'list' or not. The final value will actually be a string but it seems it is usually faster to join a list of strings than to concat them one by one. .join() takes an iterable o

Re: Fast recursive generators?

2011-10-28 Thread Gabriel Genellina
En Fri, 28 Oct 2011 15:10:14 -0300, Michael McGlothlin escribió: I'm trying to generate a list of values where each value is dependent on the previous value in the list and this bit of code needs to be repeatedly so I'd like it to be fast. It doesn't seem that comprehensions will work as each