Announce: Parametric Solutions (parasol)

2009-01-25 Thread Charlie Taylor
Parasol is a python framework in which mathematical models can be investigated parametrically. Parasol enables easy optimization, sensitivity study, and visualization. The math model can be as big or as small as desired. Output is generated in plain text, HTML, and native Microsoft Suite files

Re: Does Python really follow its philosophy of Readability counts?

2009-01-25 Thread Luis Zarrabeitia
Quoting Russ P. russ.paie...@gmail.com: On Jan 24, 9:54 pm, Luis Zarrabeitia ky...@uh.cu wrote: Quoting Russ P. russ.paie...@gmail.com: It is. For starters, I'd lose the information of this attribute was intended to be internal and I'm accessing it anyway. Not really. When you get a

Pythonic list/tuple/dict layout?

2009-01-25 Thread Akira Kitada
Hi, There is more than one way to write a list/tuple/dict in Python, and actually different styles are used in standard library. As a hobgoblin of little minds, I rather like to know which style is considered Pythonic in the community. I collected common layout from existing code and pasted them

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Stephen Hansen
and pasted them below. My vote would go to d1. How about yours? Whatever reads best within the context of the specific code is Pythonic. -- http://mail.python.org/mailman/listinfo/python-list

Plugin system, RuntimeWarning: Parent module 'ext_abc' not found while handling absolute import

2009-01-25 Thread Torsten Mohr
Hi, i try to write a plugin system that i want to use to let users extend a module that i write. Within the module there is an extension loader that loads an extension module. This extension module should be able to import modules from my system, which provides some extensions. Basically, this

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Dan Bishop
On Jan 25, 2:18 am, Akira Kitada akit...@gmail.com wrote: Hi, There is more than one way to write a list/tuple/dict in Python, and actually different styles are used in standard library. As a hobgoblin of little minds, I rather like to know which style is considered Pythonic in the

Re: A different kind of interface

2009-01-25 Thread Marc 'BlackJack' Rintsch
On Sat, 24 Jan 2009 01:02:01 +0100, Дамјан Георгиевски wrote: I don't know what an IBQ is. +IBQ- seems to be the way your newsreader displays the dashes that where in Ben's posting. I see em dash characters there: I see IBQ too ... also weird is that he has Content-Type: text/plain;

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Akira Kitada
Wow! A Python debate over curly brace placement! Imagine that! PEP8 even deals with tabs vs spaces, where to put a blank line, etc :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Regex for Python 2.7

2009-01-25 Thread Gabriel Genellina
En Sat, 24 Jan 2009 21:51:31 -0200, MRAB goo...@mrabarnett.plus.com escribió: Gabriel Genellina wrote: En Sat, 24 Jan 2009 18:23:51 -0200, MRAB goo...@mrabarnett.plus.com escribió: Some time ago I discovered this difference between regular expressions in Python and Perl: Python

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Michael Iatrou
When the date was Sunday 25 January 2009, Akira Kitada wrote: There is more than one way to write a list/tuple/dict in Python, and actually different styles are used in standard library. I would vote for d1, but I don't think that this is more pythonic, I just consider it more clean,

IDLE/Python on Asus EEE PC

2009-01-25 Thread Alex van der Spek
Simple Python programs edited and run through IDLE work fine on my Ubuntu Linux system without any editing. However on my Asus EEE PC IDLE complains about incorrect formatting (indentation) or possibly mixing tabs/spaces. The source code is exactly the same. There is no incorrect formatting

Re: Dynamic methods and lambda functions

2009-01-25 Thread Kay Schluehr
On 23 Jan., 13:28, unine...@gmail.com wrote: Hi, I want to add some properties dynamically to a class, and then add the corresponding getter methods. Something resulting in this: class Person: def Getname(self): return self.__name def Getage(self): return

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Ben Finney
Akira Kitada akit...@gmail.com writes: I collected common layout from existing code and pasted them below. My vote would go to d1. How about yours? If there is consensus on this, that might be worth being included in PEP 8. Thanks, d1 = { 0: ham, 1: jam, 2: spam,

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Steven D'Aprano
On Sun, 25 Jan 2009 17:18:28 +0900, Akira Kitada wrote: Hi, There is more than one way to write a list/tuple/dict in Python, and actually different styles are used in standard library. As a hobgoblin of little minds, I rather like to know which style is considered Pythonic in the

Re: Is (-1 ==True) True or False? Neither

2009-01-25 Thread Steven D'Aprano
On Sun, 25 Jan 2009 03:07:04 +0200, Oktay Şafak wrote: The reason is that when someone writes (-1 == True) he is clearly, definitely, absolutely asking for a boolean comparison, not a numerical one. If I wrote (-1 == True), and I'm not sure why I would, I would expect to get the answer

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Akira Kitada
BTW, there's no need to use such large examples. Three items per dict would be sufficient to illustrate the styles, using ten items doesn't add anything useful to the discussion. I worried to be told 'you can make it in a line like {ham: jam, spam: alot}' ;) --

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Akira Kitada
These are the only two that follow PEP 8; the others don't have four-space indent levels. In those examples, the following sentence in PEP 8 would be applied. Make sure to indent the continued line appropriately. I actually use this style: foo = { 0: 'spam', 1: 'eggs',

Re: What is intvar?

2009-01-25 Thread W. eWatson
Steve Holden wrote: W. eWatson wrote: W. eWatson wrote: r wrote: here is a good explanation of control vars: http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html Here are 3 great Tkinter refernces in order: http://infohost.nmt.edu/tcc/help/pubs/tkinter/

Newby: how to transform text into lines of text

2009-01-25 Thread vsoler
Hello, I'va read a text file into variable a a=open('FicheroTexto.txt','r') a.read() a contains all the lines of the text separated by '\n' characters. Now, I want to work with each line separately, without the '\n' character. How can I get variable b as a list of such lines? Thank

Re: Newby: how to transform text into lines of text

2009-01-25 Thread Diez B. Roggisch
vsoler schrieb: Hello, I'va read a text file into variable a a=open('FicheroTexto.txt','r') a.read() a contains all the lines of the text separated by '\n' characters. No, it doesn't. a.read() *returns* the contents, but you don't assign it, so it is discarded. Now, I want to

ANN: new snapshot of the eric4 Pylons plugin released

2009-01-25 Thread Detlev Offenbach
Hi, this is to inform everybody about the availability of the Pylons plugin for eric4. It adds Pylons support to the eric4 Python IDE. The Plugin is available via the eric4 web site at http://eric-ide.python-projects.org/index.html What is eric4 - eric4 is a Python IDE, that comes

Re: *.python.org broken?

2009-01-25 Thread Cousin Stanley
Is anybody else having trouble accessing sites (including www, docs, wiki) in the python.org tree, or is it just me? (Or just .au?) Yes, connecting to python.org sites has been problematic for me as well I don't remember when the trouble started, but it's been problematic for at

Re: Newby: how to transform text into lines of text

2009-01-25 Thread Tim Chase
The idiomatic way would be iterating over the file-object itself - which will get you the lines: with open(foo.txt) as inf: for line in inf: print line In versions of Python before the with was introduced (as in the 2.4 installations I've got at both home and work), this can

Re: Newby: how to transform text into lines of text

2009-01-25 Thread vsoler
On 25 ene, 14:36, Diez B. Roggisch de...@nospam.web.de wrote: vsoler schrieb: Hello, I'va read a text file into variable a      a=open('FicheroTexto.txt','r')      a.read() a contains all the lines of the text separated by '\n' characters. No, it doesn't. a.read() *returns* the

Re: *.python.org broken?

2009-01-25 Thread Steve Holden
Cousin Stanley wrote: Is anybody else having trouble accessing sites (including www, docs, wiki) in the python.org tree, or is it just me? (Or just .au?) Yes, connecting to python.org sites has been problematic for me as well I don't remember when the trouble started, but it's

Re: Python 3: range objects cannot be sliced

2009-01-25 Thread Alan G Isaac
On 1/16/2009 3:13 PM Alan G Isaac apparently wrote: It is documented: http://docs.python.org/3.0/library/stdtypes.html#sequence-types-str-bytes-bytearray-list-tuple-range But then again, the opposite is also documented, since `range` is a sequence type. Quoting: Sequences also support

Re: IDLE/Python on Asus EEE PC

2009-01-25 Thread MRAB
Alex van der Spek wrote: Simple Python programs edited and run through IDLE work fine on my Ubuntu Linux system without any editing. However on my Asus EEE PC IDLE complains about incorrect formatting (indentation) or possibly mixing tabs/spaces. The source code is exactly the same. There is

Re: *.python.org broken?

2009-01-25 Thread Akira Kitada
http://downforeveryoneorjustme.com/ On Sun, Jan 25, 2009 at 10:06 AM, tgvaug...@gmail.com wrote: Hi all, Is anybody else having trouble accessing sites (including www, docs, wiki) in the python.org tree, or is it just me? (Or just .au?) Cheers, Tim --

[MacOS] Multiple versions of a module

2009-01-25 Thread Pierre-Alain Dorange
How to manage a module with several versions on MacOS X ? All modules are installed in : /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-pa ckages/ This is the default path for Mac. But for some modules i need several version (stable 1.8.1 and test 1.9.0 for example : for

Re: Byte oriented data types in python

2009-01-25 Thread Ravi
Take a look at the struct and ctypes modules. struct is really not the choice. it returns an expanded string of the data and this means larger latency over bluetooth. ctypes is basically for the interface with libraries written in C (this I read from the python docs) --

Re: Byte oriented data types in python

2009-01-25 Thread Ravi
On Jan 25, 12:52 am, Martin v. Löwis mar...@v.loewis.de wrote: packet_type (1 byte unsigned) || packet_length (1 byte unsigned) || packet_data(variable) How to construct these using python data types, as int and float have no limits and their sizes are not well defined. In Python 2.x,

Re: progress: compiling python2.5 under msys (specifically but not exclusively under wine) with msvcr80

2009-01-25 Thread Luke Kenneth Casson Leighton
Have you made some benchmarks like pystone? Cheers, Cesare Cesare, hi, thanks for responding: unfortunately, there's absolutely no point in making any benchmark figures under an emulated environment which does things like take 2 billion instruction cycles to start up a program named

Re: [MacOS] Multiple versions of a module

2009-01-25 Thread Diez B. Roggisch
Pierre-Alain Dorange schrieb: How to manage a module with several versions on MacOS X ? All modules are installed in : /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-pa ckages/ This is the default path for Mac. But for some modules i need several version (stable 1.8.1 and

Re: Logging help

2009-01-25 Thread Aahz
In article f4fc590c-f31d-46be-b769-9d746b8b8...@w39g2000prb.googlegroups.com, koranthala koranth...@gmail.com wrote: Is it possible somehow to have the logging module rotate the files every time I start it. If you're on Linux, why not use logrotate? -- Aahz (a...@pythoncraft.com) *

Reading the first MB of a binary file

2009-01-25 Thread Max Leason
Hi, I'm attempting to read the first MB of a binary file and then do a md5 hash on it so that i can find the file later despite it being moved or any file name changes that may have been made to it. These files are large (350-1400MB) video files and i often located on a different computer and I

Re: progress: compiling python2.5 under msys (specifically but not exclusively under wine) with msvcr80

2009-01-25 Thread Ross Ridge
Luke Kenneth Casson Leighton l...@lkcl.net wrote: this is a progress report on compiling python using entirely free software tools, no proprietary compilers or operating systems involved, yet still linking and successfully running with msvcr80 assemblies. MSVCR80.DLL is part of the Microsoft

Re: Reading the first MB of a binary file

2009-01-25 Thread MRAB
Max Leason wrote: Hi, I'm attempting to read the first MB of a binary file and then do a md5 hash on it so that i can find the file later despite it being moved or any file name changes that may have been made to it. These files are large (350-1400MB) video files and i often located on a

Efficient multi-slicing technique?

2009-01-25 Thread python
Is there an efficient way to multi-slice a fixed with string into individual fields that's logically equivalent to the way one would slice a delimited string using .split()? Background: I'm parsing some very large, fixed line-width text files that have weekly columns of data (52 data columns plus

Re: Byte oriented data types in python

2009-01-25 Thread Steve Holden
Ravi wrote: Take a look at the struct and ctypes modules. struct is really not the choice. it returns an expanded string of the data and this means larger latency over bluetooth. If you read the module documentation more carefully you will see that it converts between the various native

Counting number of objects

2009-01-25 Thread Kottiyath
Hi, I am creating a class called people - subclasses men, women, children etc. I want to count the number of people at any time. So, I created code like the following: class a(object): counter = 0 def __new__(cls, *args, **kwargs): a.counter += 1 return object.__new__(cls,

Re: Counting number of objects

2009-01-25 Thread Steve Holden
Kottiyath wrote: Hi, I am creating a class called people - subclasses men, women, children etc. I want to count the number of people at any time. So, I created code like the following: class a(object): counter = 0 def __new__(cls, *args, **kwargs): a.counter += 1

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Ravi ra.ravi@gmail.com wrote: Take a look at the struct and ctypes modules. struct is really not the choice. it returns an expanded string of the data and this means larger latency over bluetooth. I don't know what you mean by returns an expanded string of the data. I do

Re: Counting number of objects

2009-01-25 Thread Andreas Waldenburger
On Sun, 25 Jan 2009 09:23:35 -0800 (PST) Kottiyath n.kottiy...@gmail.com wrote: Hi, I am creating a class called people - subclasses men, women, children etc. I want to count the number of people at any time. So, I created code like the following: class a(object): counter = 0

Re: Does Python really follow its philosophy of Readability counts?

2009-01-25 Thread Mark Wooding
Russ P. russ.paie...@gmail.com writes: Calling a one-word change a fork is quite a stretch, I'd say. I wouldn't. I've forked a project P if I've made a different version of it which isn't going to be reflected upstream. Now I've got to maintain my fork, merging in changes from upstream as

Re: Does Python really follow its philosophy of Readability counts?

2009-01-25 Thread Mark Wooding
Russ P. russ.paie...@gmail.com writes: Imagine a person who repairs computers. He is really annoyed that he constantly has to remove the cover to get at the guts of the computer. So he insists that computers cases should be made without covers. Poor analogy. He gets fed up that the computers

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Rhamphoryncus
d1 -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of Readability counts?

2009-01-25 Thread Russ P.
On Jan 25, 10:04 am, Mark Wooding m...@distorted.org.uk wrote: Russ P. russ.paie...@gmail.com writes: Calling a one-word change a fork is quite a stretch, I'd say. I wouldn't.  I've forked a project P if I've made a different version of it which isn't going to be reflected upstream.  Now

Monitor a FTP site for arrival of new/updated files

2009-01-25 Thread python
Any suggestions on a best practice way to monitor a remote FTP site for the arrival of new/updated files? I don't need specific code, just some coaching on technique based on your real-world experience including suggestions for a utility vs. code based solution. My goal is to maintain a local

Re: Efficient multi-slicing technique?

2009-01-25 Thread MRAB
pyt...@bdurham.com wrote: Is there an efficient way to multi-slice a fixed with string into individual fields that's logically equivalent to the way one would slice a delimited string using .split()? Background: I'm parsing some very large, fixed line-width text files that have weekly

Re: Byte oriented data types in python

2009-01-25 Thread Stephen Hansen
On Sun, Jan 25, 2009 at 7:27 AM, Ravi ra.ravi@gmail.com wrote: Take a look at the struct and ctypes modules. struct is really not the choice. it returns an expanded string of the data and this means larger latency over bluetooth. Noo... struct really IS the choice; that is the

Re: Byte oriented data types in python

2009-01-25 Thread Martin v. Löwis
Take a look at the struct and ctypes modules. struct is really not the choice. it returns an expanded string of the data and this means larger latency over bluetooth. I don't know what you mean by returns an expanded string of the data. I do know that struct does exactly what you

Re: Does Python really follow its philosophy of Readability counts?

2009-01-25 Thread Mark Wooding
Steven D'Aprano st...@remove-this-cybersource.com.au writes: On Fri, 23 Jan 2009 21:36:59 -0500, Luis Zarrabeitia wrote: It makes sense... if the original author is an egotist who believes he must control how I use that library. Then I guess Guido must be such an egotist, because there's

Re: Does Python really follow its philosophy of Readability counts?

2009-01-25 Thread Russ P.
On Jan 25, 10:04 am, Mark Wooding m...@distorted.org.uk wrote: But what if I want an automatic check to verify that I am using it as the author intended? Is that unreasonable? You mean that you can't /tell/ whether you typed mumble._seekrit? You're very strange.  It's kind of hard to do by

Re: Newby: how to transform text into lines of text

2009-01-25 Thread John Machin
On Jan 26, 12:54 am, Tim Chase python.l...@tim.thechases.com wrote: One other caveat here, line contains the newline at the end, so you might have   print line.rstrip('\r\n') to remove them. I don't understand the presence of the '\r' there. Any '\x0d' that remains after reading the file

Re: Monitor a FTP site for arrival of new/updated files

2009-01-25 Thread Steve Holden
pyt...@bdurham.com wrote: Any suggestions on a best practice way to monitor a remote FTP site for the arrival of new/updated files? I don't need specific code, just some coaching on technique based on your real-world experience including suggestions for a utility vs. code based solution.

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Martin v. Löwis mar...@v.loewis.de wrote: Take a look at the struct and ctypes modules. struct is really not the choice. it returns an expanded string of the data and this means larger latency over bluetooth. I don't know what you mean by returns an expanded string of the

Re: Doc for extended call syntax; was: Re: unzip array of arrays?

2009-01-25 Thread Mark Wooding
Steve Holden st...@holdenweb.com writes: No, you aren't mistaken. Looking at the * symbol in the 2.6 documentation index it lists only two references. The first is the language manual's explanation of its use in the def statement, the second is a transitory reference to its use in function

Re: Byte oriented data types in python

2009-01-25 Thread Martin v. Löwis
I disagree. He has a format (type, length, value), with the value being variable-sized. How do you do that in the struct module? You construct a format string for the value portion based on the type/length header. Can you kindly provide example code on how to do this? I don't see how

Re: Monitor a FTP site for arrival of new/updated files

2009-01-25 Thread python
Well, the ftpmirror will cope with most of what you want to do as it is, but I am unsure how you can determine whether a file is in the process of being written on the server. Looks like that may be a fit. Thank you Steve! Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading the first MB of a binary file

2009-01-25 Thread Marc 'BlackJack' Rintsch
On Sun, 25 Jan 2009 08:37:07 -0800, Max Leason wrote: I'm attempting to read the first MB of a binary file and then do a md5 hash on it so that i can find the file later despite it being moved or any file name changes that may have been made to it. These files are large (350-1400MB) video

Cartesian Product of two lists (itertools)

2009-01-25 Thread Thorsten Kampe
Hi, is there a way to make itertools.product generate triples instead of pairs from two lists? For example: list1 = [1, 2]; list2 = [4, 5]; list3 = [7, 8] from itertools import product list(product(list1, list2, list3)) [(1, 4, 7), (1, 4, 8), (1, 5, 7), (1, 5, 8), (2, 4, 7), (2, 4, 8), (2,

v = json.loads({'test':'test'})

2009-01-25 Thread gert
raise ValueError(errmsg(Expecting property name, s, end)) http://docs.python.org/library/json.html What am I doing wrong ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Mark Wooding
Akira Kitada akit...@gmail.com writes: I collected common layout from existing code and pasted them below. My vote would go to d1. How about yours? It seems that I use both d1 and d4, though in both cases I omit the trailing commas. I use d1 when each item is on a separate line, and d4 when

Re: Byte oriented data types in python

2009-01-25 Thread John Machin
On Jan 26, 2:28 am, Ravi ra.ravi@gmail.com wrote: On Jan 25, 12:52 am, Martin v. Löwis mar...@v.loewis.de wrote: packet_type (1 byte unsigned) || packet_length (1 byte unsigned) || packet_data(variable) How to construct these using python data types, as int and float have no

Re: Byte oriented data types in python

2009-01-25 Thread Martin v. Löwis
Looks to me like there was already a reasonable way of getting a bytes object containing a variable number of zero bytes. Any particular reason why bytes(n) was given this specialised meaning? I think it was because bytes() was originally mutable, and you need a way to create a buffer of n

Re: v = json.loads({'test':'test'})

2009-01-25 Thread Peter Otten
gert wrote: raise ValueError(errmsg(Expecting property name, s, end)) http://docs.python.org/library/json.html What am I doing wrong ? You need proper quotation marks: s = json.dumps({'test':'test'}) s '{test: test}' json.loads(s) {u'test': u'test'} The JSON format is described here:

Re: v = json.loads({'test':'test'})

2009-01-25 Thread livibetter
On Jan 26, 5:12 am, gert gert.cuyk...@gmail.com wrote: raise ValueError(errmsg(Expecting property name, s, end))http://docs.python.org/library/json.html What am I doing wrong ? You use wrong quotes, it should be wrapped by double quotes not single quotes. Read http://json.org/: A string is

Re: v = json.loads({'test':'test'})

2009-01-25 Thread J. Clifford Dyer
Please include all relevant information in the *body* of your message, not just in the subject. It's a pain having to piece a question back together between the subject. On Sun, 2009-01-25 at 13:12 -0800, gert wrote: raise ValueError(errmsg(Expecting property name, s, end))

Re: Securing a database

2009-01-25 Thread M.-A. Lemburg
On 2009-01-23 08:26, kt83...@gmail.com wrote: My company provides some services online, which now they are planning to make it offline and sell to customers who can use it in their networks. One of our major moneywinners is some data which is stored in a database. Now, this data inside the

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Martin v. Löwis mar...@v.loewis.de wrote: You construct a format string for the value portion based on the type/length header. Can you kindly provide example code on how to do this? OK, something like this to handle received data where there is an initial 8-bit type field that

Re: v = json.loads({'test':'test'})

2009-01-25 Thread Дамјан Георгиевски
raise ValueError(errmsg(Expecting property name, s, end)) http://docs.python.org/library/json.html What am I doing wrong ? try this v = json.loads('{test:test}') JSON doesn't support single quotes, only double quotes. -- дамјан ( http://softver.org.mk/damjan/ ) A: Because it reverses the

Re: Cartesian Product of two lists (itertools)

2009-01-25 Thread Mensanator
On Jan 25, 3:12�pm, Thorsten Kampe thors...@thorstenkampe.de wrote: Hi, is there a way to make itertools.product generate triples instead of pairs from two lists? For example: list1 = [1, 2]; list2 = [4, 5]; list3 = [7, 8] from itertools import product list(product(list1, list2, list3))

super behavior

2009-01-25 Thread TP
Hi, Hereafter is an example using super. At the execution, we obtain: coucou init_coucou2 coucou1 coucou2 Traceback (most recent call last): File essai_heritage.py, line 34, in module print b.a AttributeError: 'coucou' object has no attribute 'a' Why Python does not enter in the __init__

Re: v = json.loads({'test':'test'})

2009-01-25 Thread gert
On Jan 25, 11:16 pm, Дамјан Георгиевски gdam...@gmail.com wrote: raise ValueError(errmsg(Expecting property name, s, end)) http://docs.python.org/library/json.html What am I doing wrong ? try this v = json.loads('{test:test}') JSON doesn't support single quotes, only double quotes. the

Re: Byte oriented data types in python

2009-01-25 Thread Martin v. Löwis
dtype = ord(rawdata[0]) dcount = struct.unpack(!H,rawdata[1:3]) if dtype == 1: fmtstr = ! + H*dcount elif dtype == 2: fmtstr = ! + f*dcount rlen = struct.calcsize(fmtstr) data = struct.unpack(fmtstr,rawdata[3:3+rlen]) leftover = rawdata[3+rlen:]

Re: Counting number of objects

2009-01-25 Thread Gabriel Genellina
En Sun, 25 Jan 2009 16:06:47 -0200, Andreas Waldenburger geekm...@usenot.de escribió: On Sun, 25 Jan 2009 09:23:35 -0800 (PST) Kottiyath n.kottiy...@gmail.com wrote: I am creating a class called people - subclasses men, women, children etc. I want to count the number of people at any

Re: Counting number of objects

2009-01-25 Thread Gabriel Genellina
En Sun, 25 Jan 2009 16:06:47 -0200, Andreas Waldenburger geekm...@usenot.de escribió: On Sun, 25 Jan 2009 09:23:35 -0800 (PST) Kottiyath n.kottiy...@gmail.com wrote: I am creating a class called people - subclasses men, women, children etc. I want to count the number of people at any

Re: v = json.loads({'test':'test'})

2009-01-25 Thread Diez B. Roggisch
gert schrieb: On Jan 25, 11:16 pm, Дамјан Георгиевски gdam...@gmail.com wrote: raise ValueError(errmsg(Expecting property name, s, end)) http://docs.python.org/library/json.html What am I doing wrong ? try this v = json.loads('{test:test}') JSON doesn't support single quotes, only double

Re: syntax color lang source code in blogs or website

2009-01-25 Thread Cliff MacGillivray
Xah Lee wrote: For those of you using emacs, here's the elisp code that allows you to syntax color computer language source code in your blog or website. http://xahlee.org/emacs/elisp_htmlize.html to comment, here: http://xahlee.blogspot.com/2009/01/dehtmlize-source-code-in-emacs-lisp.html

Re: super behavior

2009-01-25 Thread Diez B. Roggisch
TP schrieb: Hi, Hereafter is an example using super. At the execution, we obtain: coucou init_coucou2 coucou1 coucou2 Traceback (most recent call last): File essai_heritage.py, line 34, in module print b.a AttributeError: 'coucou' object has no attribute 'a' Why Python does not enter in

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Martin v. Löwis mar...@v.loewis.de wrote: dtype = ord(rawdata[0]) dcount = struct.unpack(!H,rawdata[1:3]) if dtype == 1: fmtstr = ! + H*dcount elif dtype == 2: fmtstr = ! + f*dcount rlen = struct.calcsize(fmtstr) data =

Re: v = json.loads({'test':'test'})

2009-01-25 Thread gert
On Jan 25, 11:51 pm, Diez B. Roggisch de...@nospam.web.de wrote: gert schrieb: On Jan 25, 11:16 pm, Дамјан Георгиевски gdam...@gmail.com wrote: raise ValueError(errmsg(Expecting property name, s, end)) http://docs.python.org/library/json.html What am I doing wrong ? try this v =

Re: syntax color lang source code in blogs or website

2009-01-25 Thread Tim Greer
Cliff MacGillivray wrote: Xah Lee wrote: For those of you using emacs, here's the elisp code that allows you to syntax color computer language source code in your blog or website. http:/ to comment, here: http://... Xah, Very nice! If nothing else you seem to be a pretty

Re: Newby: how to transform text into lines of text

2009-01-25 Thread Tim Chase
One other caveat here, line contains the newline at the end, so you might have print line.rstrip('\r\n') to remove them. I don't understand the presence of the '\r' there. Any '\x0d' that remains after reading the file in text mode and is removed by that rstrip would be a strange occurrence

Re: Byte oriented data types in python

2009-01-25 Thread Martin v. Löwis
Unfortunately, that does not work in the example. We have a message type (an integer), and a variable-length string. So how do you compute the struct format for that? I'm confused. Are you asking for an introductory tutorial on programming in Python? Perhaps. I honestly do not know how to

Re: v = json.loads({'test':'test'})

2009-01-25 Thread Diez B. Roggisch
But all of this is not JSON. Yes it is, you just make it more python dictionary compatible :) No, what you do is to make it more incompatible with other json-implementations. Which defies the meaning of a standard. Besides, {foo : bar} is *not* python dictionary compatible, at least not

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Martin v. Löwis mar...@v.loewis.de wrote: Unfortunately, that does not work in the example. We have a message type (an integer), and a variable-length string. So how do you compute the struct format for that? I'm confused. Are you asking for an introductory tutorial on

Re: Byte oriented data types in python

2009-01-25 Thread Martin v. Löwis
It deals with variable sized fields just fine: dtype = 18 dlength = 32 format = !BB%ds % dlength rawdata = struct.pack(format, (dtype,dlength,data)) I wouldn't call this just fine, though - it involves a % operator to even compute the format string. IMO, it is *much* better not to use

Re: v = json.loads({'test':'test'})

2009-01-25 Thread Andreas Waldenburger
On Sun, 25 Jan 2009 23:51:41 +0100 Diez B. Roggisch de...@nospam.web.de wrote: gert schrieb: {'test': 'test'} {test: test} It can not be that hard to support both notation can it ? It's not hard, but it's not standard-conform. OK, playing the devil's advocate here: Doesn't

Re: v = json.loads({'test':'test'})

2009-01-25 Thread Gabriel Genellina
En Sun, 25 Jan 2009 21:08:04 -0200, gert gert.cuyk...@gmail.com escribió: On Jan 25, 11:51 pm, Diez B. Roggisch de...@nospam.web.de wrote: gert schrieb: On Jan 25, 11:16 pm, Дамјан Георгиевски gdam...@gmail.com wrote: raise ValueError(errmsg(Expecting property name, s, end))

Re: v = json.loads({'test':'test'})

2009-01-25 Thread Steve Holden
Andreas Waldenburger wrote: On Sun, 25 Jan 2009 23:51:41 +0100 Diez B. Roggisch de...@nospam.web.de wrote: gert schrieb: {'test': 'test'} {test: test} It can not be that hard to support both notation can it ? It's not hard, but it's not standard-conform. OK, playing the devil's

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Martin v. Löwis mar...@v.loewis.de wrote: It deals with variable sized fields just fine: dtype = 18 dlength = 32 format = !BB%ds % dlength rawdata = struct.pack(format, (dtype,dlength,data)) I wouldn't call this just fine, though - it involves a % operator to even

Re: v = json.loads({'test':'test'})

2009-01-25 Thread gert
On Jan 26, 12:40 am, Diez B. Roggisch de...@nospam.web.de wrote: But all of this is not JSON. Yes it is, you just make it more python dictionary compatible :) No, what you do is to make it more incompatible with other json-implementations. Which defies the meaning of a standard. Besides,

ob_type in shared memory

2009-01-25 Thread Aaron Brady
Hello, I am writing an extension using shared memory. I need a data type that is able to reassign its 'ob_type' field depending on what process is calling it. Object 'A' is of type 'Ta'. When process 'P' is looking at it, it needs to have an 'ob_type' that is 'Ta' as process 'P' sees it. When

Re: Python 3: range objects cannot be sliced

2009-01-25 Thread Fuzzyman
On Jan 25, 2:28 pm, Alan G Isaac alan.is...@gmail.com wrote: On 1/16/2009 3:13 PM Alan G Isaac apparently wrote:   It is documented:  http://docs.python.org/3.0/library/stdtypes.html#sequence-types-str-b... But then again, the opposite is also documented, since `range` is a sequence type.  

Re: Newby: how to transform text into lines of text

2009-01-25 Thread John Machin
On 26/01/2009 10:34 AM, Tim Chase wrote: I believe that using the formulaic for line in file(FILENAME) iteration guarantees that each line will have at most only one '\n' and it will be at the end (again, a malformed text-file with no terminal '\n' may cause it to be absent from the last

Re: Efficient multi-slicing technique?

2009-01-25 Thread Tim Chase
Is there an efficient way to multi-slice a fixed with string into individual fields that's logically equivalent to the way one would slice a delimited string using .split()? Background: I'm parsing some very large, fixed line-width text files that have weekly columns of data (52 data columns plus

Re: Newby: how to transform text into lines of text

2009-01-25 Thread Scott David Daniels
John Machin wrote: On 26/01/2009 10:34 AM, Tim Chase wrote: I believe that using the formulaic for line in file(FILENAME) iteration guarantees that each line will have at most only one '\n' and it will be at the end (again, a malformed text-file with no terminal '\n' may cause it to be

Re: v = json.loads({'test':'test'})

2009-01-25 Thread Andreas Waldenburger
On Sun, 25 Jan 2009 19:04:44 -0500 Steve Holden st...@holdenweb.com wrote: Andreas Waldenburger wrote: On Sun, 25 Jan 2009 23:51:41 +0100 Diez B. Roggisch de...@nospam.web.de wrote: gert schrieb: {'test': 'test'} {test: test} It can not be that hard to support both notation can

Re: Newby: how to transform text into lines of text

2009-01-25 Thread Steven D'Aprano
On Sun, 25 Jan 2009 17:34:18 -0600, Tim Chase wrote: Thank goodness I haven't found any of my data-sources using \n\r instead, which would require me to left-strip '\r' characters as well. Sigh. My kingdom for competency. :-/ If I recall correctly, one of the accounting systems I used eight

  1   2   3   >