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

2009-01-25 Thread Hendrik van Rooyen
"Paul Rubin" wrote: > Steven D'Aprano writes: > > We're not talking specifically about Python standard library changes, > > we're talking about any project which may have more entertaining *cough* > > policies regarding API changes. > > Oh, yes, I see what you me

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

2009-01-25 Thread Michael Iatrou
When the date was Sunday 25 January 2009, pyt...@bdurham.com wrote: > Any suggestions on a best practice way to monitor a remote FTP > site for the arrival of new/updated files? For a custom solution, you may want to take a look to pyinotify: http://pyinotify.sourceforge.net/ -- Mich

Re: String comparision

2009-01-25 Thread S.Selvam Siva
Thank You Gabriel, On Sun, Jan 25, 2009 at 7:12 AM, Gabriel Genellina wrote: > En Sat, 24 Jan 2009 15:08:08 -0200, S.Selvam Siva > escribió: > > > I am developing spell checker for my local language(tamil) using python. >> I need to generate alternative word list for a miss-spelled word from th

Re: USB in python

2009-01-25 Thread Astan Chee
Tim Roberts wrote: Sorry, but you have NOT created a USB device, and I sincerely hope you do not try to plug it in to a real USB port. Sorry, by USB device, I meant a device that is powered/activated by a bunch of wires that I want to control using a computer and since I had a spare USB jack

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

2009-01-25 Thread Tim Roberts
Andreas Waldenburger wrote: > >But as gert says, the standard is "broken" by many many browsers >already We're debating relatively picky semantic point, so I won't feel bad by being picky. Browsers have nothing to do with the JSON standard. JSON is not Javascript, nor is it a part of Javascri

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

2009-01-25 Thread Gabriel Genellina
En Mon, 26 Jan 2009 00:23:30 -0200, John Machin escribió: On Jan 26, 1:03 pm, "Gabriel Genellina" wrote: It's so easy that don't doing that is just inexcusable lazyness :) Your own example, written using the csv module: import csv f = csv.reader(open('customer_x.txt','rb'), delimiter='\t'

Re: USB in python

2009-01-25 Thread Tim Roberts
Astan Chee wrote: > >Im trying to write a program for my USB device and I'm thinking of using >python to do this. The USB device is of my own making and it is >activated when one of the two data pins of the USB is given about 5V (or >similar to whatever the power pin is getting). Now I'm confus

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

2009-01-25 Thread Russ P.
On Jan 25, 7:56 pm, Mark Wooding wrote: > "Russ P." writes: > > [snip stuff I don't disagree with] > > > That makes renaming and refactoring riskier in general in Python than > > in statically typed languages with enforced access restrictions. More > > care and attention to detail is needed to do

Re: Python

2009-01-25 Thread skip
Terry> porkodi wrote: >> www.easythings5.blogspot.com Terry> Ad spam site with pirated semi-gibberish not even containing Terry> 'Python'. Yeah, my fault. I was poking through a bunch of held messages and saw "Pyhon" as the subject. Didn't even look at the message itself until

Re: Python

2009-01-25 Thread Terry Reedy
porkodi wrote: www.easythings5.blogspot.com Ad spam site with pirated semi-gibberish not even containing 'Python'. -- http://mail.python.org/mailman/listinfo/python-list

Re: is None vs. == None

2009-01-25 Thread Terry Reedy
Roger wrote: And, just for completeness, the "is" test is canonical precisely because the interpreter guarantees there is only ever one object of type None, so an identity test is always appropriate. Even the copy module doesn't create copies ... Does the interpreter guarantee the same for Fal

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

2009-01-25 Thread Mark Wooding
"Russ P." writes: [snip stuff I don't disagree with] > That makes renaming and refactoring riskier in general in Python than > in statically typed languages with enforced access restrictions. More > care and attention to detail is needed to do it right in Python. In fact, I don't disagree with

Re: ob_type in shared memory

2009-01-25 Thread Mark Wooding
Aaron Brady writes: > 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. That sounds scary! > Object 'A' is of type 'Ta'. When process 'P' is looking at it, it > needs to have an 'ob_type'

Re: Byte oriented data types in python

2009-01-25 Thread John Machin
On Jan 26, 10:53 am, "Martin v. Löwis" 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

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

2009-01-25 Thread Gabriel Genellina
En Sun, 25 Jan 2009 04:55:47 -0200, Torsten Mohr escribió: 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

Re: Python 3: range objects cannot be sliced

2009-01-25 Thread John Machin
On Jan 26, 12:08 pm, Terry Reedy wrote: > Fuzzyman wrote: > > On Jan 25, 2:28 pm, Alan G Isaac 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 oppos

Re: Why is it faster the second time ?

2009-01-25 Thread Philip Semanchuk
On Jan 23, 2009, at 12:46 PM, jalanb3 wrote: Hello the group, I am wondering why doctests run slower the first time. In the transcript below "try" is a script which finds and runs doctests in the current directory. It also shows how long it takes to run these tests. I added a new test which s

Re: Counting number of objects

2009-01-25 Thread Mark Wooding
Andreas Waldenburger writes: > On Sun, 25 Jan 2009 09:23:35 -0800 (PST) Kottiyath > wrote: > >> class a(object): >> counter = 0 >> def __new__(cls, *args, **kwargs): >> a.counter += 1 >> return object.__new__(cls, *args, **kwargs) Hmm. Exceptions raised during object cr

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

2009-01-25 Thread Russ P.
On Jan 25, 5:31 pm, Steven D'Aprano wrote: > It seems to me that Russ' latest objection to _private names is not > specific to _private names. The same problem: > > "You will get no warning at all. You will just be inadvertently > creating a new "private" attribute -- and the assignment that you

Re: Efficient multi-slicing technique?

2009-01-25 Thread Tim Chase
I'm not sure if it's more efficient, but there's the struct module: http://docs.python.org/library/struct.html Thanks for your suggestion. I've been experimenting with this technique, but my initial tests don't show any performance improvements over using slice() objects to slice a string. Howev

Why is it faster the second time ?

2009-01-25 Thread jalanb3
Hello the group, I am wondering why doctests run slower the first time. In the transcript below "try" is a script which finds and runs doctests in the current directory. It also shows how long it takes to run these tests. I added a new test which searches recursively for files given a path, and i

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

2009-01-25 Thread Matt Nordhoff
Matt Nordhoff wrote: > gert wrote: >> On Jan 25, 11:16 pm, Дамјан Георгиевски 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 s

Re: Securing a database

2009-01-25 Thread Peter Pearson
On Fri, 23 Jan 2009 06:10:31 -0800 (PST), kt83...@gmail.com wrote: > On Jan 23, 4:41 pm, Bryan Olson wrote: [snip] >> Look up DRM technology companies, such as CloakWare, Macrovision, and >> Cryptography Research. >> >> If you have a modest number of customers, hardware solutions and/or >> strict

Re: I'm a python addict !

2009-01-25 Thread Andreas Waldenburger
On Sat, 24 Jan 2009 23:53:17 + MRAB wrote: > Terry Reedy wrote: > > For a Python 'program', see http://xkcd.com/534/ > > > It doesn't follow PEP 8! So Randall can just forget about getting xkcd in the Standard Library. Let this be an example to all of you­! /W -- My real email address is

Re: Securing a database

2009-01-25 Thread kt83313
On Jan 23, 4:41 pm, Bryan Olson wrote: > kt83...@gmail.com wrote: > > Anyways, if we can make it real hard for them to analyze also, I think > > we are in the good - esp since the clients are not extremely rich > > enough to go for professional analyzers -- > > Sounds like you have the "digital ri

Re: *.python.org broken?

2009-01-25 Thread tgvaughan
Hi Tim, thanks for your post. I could resolve but not ping, which has been the situation for the last couple of days. But not any more! I was just in the process of checking whether or not I could connect via another ISP when I discovered that the problem has apparently fixed itself. Which is great

Python

2009-01-25 Thread porkodi
www.easythings5.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: A different kind of interface

2009-01-25 Thread Дамјан Георгиевски
>> 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; charset=utf-7 -- дамјан ( http://softver.org.mk/damjan/ ) G

Re: is None vs. == None

2009-01-25 Thread Roger
> Why do you think it matters? Intellectual curiosity hence why I asked the question. It doesn't matter if I know why the sky is blue but it's interesting to know regardless. -- http://mail.python.org/mailman/listinfo/python-list

Re: is None vs. == None

2009-01-25 Thread Roger
> And, just for completeness, the "is" test is canonical precisely because > the interpreter guarantees there is only ever one object of type None, > so an identity test is always appropriate. Even the copy module doesn't > create copies ... > Does the interpreter guarantee the same for False and

Re: OCaml, Language syntax, and Proof Systems

2009-01-25 Thread Jon Harrop
Xah Lee wrote: > ok, i've been reading these Ocaml tutorials in the past few days: > > intro to ocaml, from official site > http://caml.inria.fr/pub/docs/manual-ocaml/manual003.html > > “Objective CAML Tutorial”, most cited tutorial on the web > http://www.ocaml-tutorial.org/ > > The best one, i

Re: Securing a database

2009-01-25 Thread Bryan Olson
kt83...@gmail.com wrote: Thank you very much Bryan. It does look like this is out of my league. As Peter Pearson noted, "It is out of *everyone's* league." And Peter used to work for Cryptography Research, a small company that scored as high in this league as anyone. Maybe you can advance the

Re: seeking to improve Python skills

2009-01-25 Thread Aahz
In article , mk wrote: > >However, unit tests are a tougher cookie, do you have any resource >that's truly worth recommending for learning unit tests? Start with the doctest module. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ Weinberg's Second Law: If bui

Re: OCaml, Language syntax, and Proof Systems

2009-01-25 Thread Xah Lee
Just a quick relpy. Jon's tutorial: http://www.ffconsultancy.com/products/ocaml_for_scientists/chapter1.html is by far the best tutorial of Ocaml. It is far better than the official intro to ocaml at “caml.inria.fr” or the popularly cited tutorial at “ocaml-tutorial.org” . Jon's tutorial, namel

Where to put configuration/data files

2009-01-25 Thread Jay Bloodworth
Is there a nice cross-platform way to figure out the Right (tm) place to store configuration files and other data? Jay -- http://mail.python.org/mailman/listinfo/python-list

Re: Python C API (PyObject_CallMethod clear object)

2009-01-25 Thread Gabriel Genellina
En Sun, 25 Jan 2009 23:46:01 -0200, escribió: I have a problm with deallocating stuff. I call a function with this command: PyObject *rvalue = PyObject_CallMethod(obj, "execute","",NULL); if(rvalue==NULL) PyErr_Print(); else Py_DECREF(rvalue); Can it be, that something is missing h

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

2009-01-25 Thread John Machin
On Jan 26, 1:03 pm, "Gabriel Genellina" wrote: > En Sun, 25 Jan 2009 23:30:33 -0200, Tim Chase   > escribió: > > > > > Unfortunately, a raw rstrip() eats other whitespace that may be   > > important.  I frequently get tab-delimited files, using the following   > > pseudo-code: > > >    def clean_

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

2009-01-25 Thread Matt Nordhoff
gert wrote: > On Jan 25, 11:16 pm, Дамјан Георгиевски 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 doub

Re: Efficient multi-slicing technique?

2009-01-25 Thread python
Tim, > I'm not sure if it's more efficient, but there's the struct module: > http://docs.python.org/library/struct.html Thanks for your suggestion. I've been experimenting with this technique, but my initial tests don't show any performance improvements over using slice() objects to slice a strin

Re: A java hobbyist programmer learning python

2009-01-25 Thread TheFlyingDutchman
>         If you're building an extension tree, you'll either have to supply > layers of getter/setter methods, or hand-mangle references to attributes > defined in the superclass. > >         Say you start with a "Point2D" class, and make the X, Y coordinates > double underscore. > >         Now e

Re: Cartesian Product of two lists (itertools)

2009-01-25 Thread Mark Wooding
Thorsten Kampe writes: > [((1, 4), 7), ((1, 4), 8), ((1, 5), 7), ((1, 5), 8), ((2, 4), 7), ((2, > 4), 8), ((2, 5), 7), ((2, 5), 8)] [...] > What's the best way to pre-process the arguments to "itertools.product" > or to post-process the result of "itertools.product" to get what I > want?! P

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

2009-01-25 Thread Mark Wooding
"Russ P." writes: > On Jan 25, 10:04 am, Mark Wooding wrote: > > But what if you type "mumble._seekrit" in several places, then the > library implementer decides to give in to your nagging and makes it > "public" by changing it to "mumble.seekrit". There's a possibly better fix: introduce a pro

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

2009-01-25 Thread Gabriel Genellina
En Sun, 25 Jan 2009 23:30:33 -0200, Tim Chase escribió: Unfortunately, a raw rstrip() eats other whitespace that may be important. I frequently get tab-delimited files, using the following pseudo-code: def clean_line(line): return line.rstrip('\r\n').split('\t') f = file('cu

Re: Byte oriented data types in python

2009-01-25 Thread Stephen Hansen
> > However, as you keep claiming that the struct module is what > should be used, I must be missing something about the struct > module. You seem to be focusing overly on the "C Struct" part of the description of what the struct module does, instead of the part where it says, "packed binary data

Re: Why this code is working?

2009-01-25 Thread r
Actually Alex, i have not stopped working on getting Python into SU in one form or another since that crazy post of mine almost 3 moths ago. I have many people in the SU community asking me almost daily when i will get finished. I have a lot of work to do at this point but i will keep fighting beca

Python C API (PyObject_CallMethod clear object)

2009-01-25 Thread googler . 1 . webmaster
Hi! I have a problm with deallocating stuff. I call a function with this command: PyObject *rvalue = PyObject_CallMethod(obj, "execute","",NULL); if(rvalue==NULL) PyErr_Print(); else Py_DECREF(rvalue); Can it be, that something is missing here? Imagine I allocate an object of a type: t

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

2009-01-25 Thread Paul Rubin
Steven D'Aprano writes: > We're not talking specifically about Python standard library changes, > we're talking about any project which may have more entertaining *cough* > policies regarding API changes. Oh, yes, I see what you mean. That's a problem even in small projects, sometimes even in

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

2009-01-25 Thread Steven D'Aprano
On Sun, 25 Jan 2009 17:15:47 -0800, Paul Rubin wrote: > Steven D'Aprano writes: >> How is this scenario different from an API change where >> self.some_attribute gets changed to self.attribute? > > That would be a backward incompatible change to a published interface, > something that should not

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

2009-01-25 Thread Tim Chase
Scott David Daniels wrote: Here's how I'd do it: with open('deheap/deheap.py', 'rU') as source: for line in source: print line.rstrip() # Avoid trailing spaces as well. This should handle \n, \r\n, and \n\r lines. Unfortunately, a raw rstrip() eats other whitespace

Re: What is intvar?

2009-01-25 Thread r
W. eWatson, I contacted the author of New Mexico Techs "Introduction to Tkinter" a couple of weeks ago. He is going to update the reference material with a few missing widgets and some info on Photo and Bitmap classes. I really love the NMT layout and use it quite often. Fredricks Tkinterbook is m

Re: Why this code is working?

2009-01-25 Thread r
On Jan 23, 10:02 pm, alex23 wrote: [snip] > How's that Python bridge to SketchUp coming > along? It's been months already, surely you've invested as much effort > into learning Python as you have in talking about it? Thanks for asking Alex23, The ball is rolling on the Python SketchUp integration

Re: Cartesian Product of two lists (itertools)

2009-01-25 Thread Terry Reedy
Thorsten Kampe 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)) [(1, 4, 7), (1, 4, 8), (1, 5, 7), (1, 5, 8), (2, 4

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

2009-01-25 Thread Paul Rubin
Steven D'Aprano writes: > How is this scenario different from an API change where > self.some_attribute gets changed to self.attribute? That would be a backward incompatible change to a published interface, something that should not be done without a good reason, and which was mostly avoided th

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

2009-01-25 Thread Steven D'Aprano
On Mon, 26 Jan 2009 00:59:48 +, Steven D'Aprano wrote: > How is this scenario different from an API change where public_method() > gets changed to method()? Sorry, that's a poor example, since you were talking about attributes rather than methods. Must stop posting before coffee *wink* Rew

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

2009-01-25 Thread Steven D'Aprano
On Sun, 25 Jan 2009 19:04:44 -0500, Steve Holden wrote: > Andreas Waldenburger wrote: >> On Sun, 25 Jan 2009 23:51:41 +0100 "Diez B. Roggisch" >> wrote: >> >>> gert schrieb: {'test': 'test'} {"test": "test"} It can not be that hard to support both notation can it ? >>> It's n

Re: Python 3: range objects cannot be sliced

2009-01-25 Thread Terry Reedy
Fuzzyman wrote: On Jan 25, 2:28 pm, Alan G Isaac 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. Quotin

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

2009-01-25 Thread Steven D'Aprano
On Sun, 25 Jan 2009 12:01:16 -0800, Russ P. wrote: > On Jan 25, 10:04 am, Mark Wooding 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? >> Yo

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 e

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

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

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 ab

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 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 l

Re: Python 3: range objects cannot be sliced

2009-01-25 Thread Fuzzyman
On Jan 25, 2:28 pm, Alan G Isaac 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.  Quoting: > >  

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: v = json.loads("{'test':'test'}")

2009-01-25 Thread gert
On Jan 26, 12:40 am, "Diez B. Roggisch" 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, {foo :

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Martin v. Löwis 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 comp

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" > 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: v = json.loads("{'test':'test'}")

2009-01-25 Thread Gabriel Genellina
En Sun, 25 Jan 2009 21:08:04 -0200, gert escribió: On Jan 25, 11:51 pm, "Diez B. Roggisch" wrote: gert schrieb: > On Jan 25, 11:16 pm, Дамјан Георгиевски wrote: >>> raise ValueError(errmsg("Expecting property name", s, end)) >>>http://docs.python.org/library/json.html >>> What am I doing wro

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

2009-01-25 Thread Andreas Waldenburger
On Sun, 25 Jan 2009 23:51:41 +0100 "Diez B. Roggisch" 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 practicali

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

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Martin v. Löwis 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 >> programmin

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 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

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 occurrenc

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

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

2009-01-25 Thread gert
On Jan 25, 11:51 pm, "Diez B. Roggisch" wrote: > gert schrieb: > > > On Jan 25, 11:16 pm, Дамјан Георгиевски 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('{"te

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Martin v. Löwis 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 = struct.unpack(fmtstr

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 print b.a AttributeError: 'coucou' object has no attribute 'a' Why Python does not enter in the

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 Xah

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

2009-01-25 Thread Diez B. Roggisch
gert schrieb: On Jan 25, 11:16 pm, Дамјан Георгиевски 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 fu

Re: Counting number of objects

2009-01-25 Thread Gabriel Genellina
En Sun, 25 Jan 2009 16:06:47 -0200, Andreas Waldenburger escribió: On Sun, 25 Jan 2009 09:23:35 -0800 (PST) Kottiyath wrote: 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:

Re: Counting number of objects

2009-01-25 Thread Gabriel Genellina
En Sun, 25 Jan 2009 16:06:47 -0200, Andreas Waldenburger escribió: On Sun, 25 Jan 2009 09:23:35 -0800 (PST) Kottiyath wrote: 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:

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[

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

2009-01-25 Thread gert
On Jan 25, 11:16 pm, Дамјан Георгиевски 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 f

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 print b.a AttributeError: 'coucou' object has no attribute 'a' Why Python does not enter in the __init__ metho

Re: Cartesian Product of two lists (itertools)

2009-01-25 Thread Mensanator
On Jan 25, 3:12�pm, Thorsten Kampe 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)) > > [(1,

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 revers

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Martin v. Löwis 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 is 1 for 1

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

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)) > http://docs.pyth

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

2009-01-25 Thread livibetter
On Jan 26, 5:12 am, gert 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 a collection of

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 de

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 b

Re: Byte oriented data types in python

2009-01-25 Thread John Machin
On Jan 26, 2:28 am, Ravi wrote: > On Jan 25, 12:52 am, "Martin v. Löwis" 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

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Mark Wooding
Akira Kitada 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 I'm packing them

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

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

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

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: 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

  1   2   >