Re: read text file byte by byte

2009-12-12 Thread Dave Angel
daved170 wrote: On Dec 13, 2:34 am, Dennis Lee Bieber wrote: On Sat, 12 Dec 2009 10:46:01 +0100, census declaimed the following in gmane.comp.python.general: def scramble (a): return (a + 13) % 256 I'll see your modulo rot 13 and raise with a exclusive or... -=-=-=

Re: read text file byte by byte

2009-12-12 Thread Lie Ryan
On 12/13/2009 5:15 PM, daved170 wrote: Thank you all. Dennis I really liked you solution for the issue but I have two question about it: 1) My origin file is Text file and not binary 2) I need to read each time 1 byte. I didn't see that on your example code. That's where you're confusing things

Re: parse a string of parameters and values

2009-12-12 Thread Steven D'Aprano
On Sun, 13 Dec 2009 05:52:04 +, John Machin wrote: > Steven D'Aprano REMOVE-THIS-cybersource.com.au> writes: [snip] >> If you have multiple keys per line, you need a more sophisticated way >> of splitting them. Something like this should work: [...] > There appears to be a problem with the ab

Re: read text file byte by byte

2009-12-12 Thread Steven D'Aprano
On Sat, 12 Dec 2009 22:15:50 -0800, daved170 wrote: > Thank you all. > Dennis I really liked you solution for the issue but I have two question > about it: > 1) My origin file is Text file and not binary That's a statement, not a question. > 2) I need to read each time 1 byte. f = open(filena

Nanoengineer-1 Simulator

2009-12-12 Thread technologiclee
This is from a thread started at the Open Manufacturing Group. It is about the Nanoengineer-1 molecular modeling program. It is released under GPL license. I would like to know if this project can be forked and continued - as development seems to have ceased, but it is still the best software of

Re: read text file byte by byte

2009-12-12 Thread daved170
On Dec 13, 2:34 am, Dennis Lee Bieber wrote: > On Sat, 12 Dec 2009 10:46:01 +0100, census > declaimed the following in gmane.comp.python.general: > > > > > def scramble (a): return (a + 13) % 256 > >         I'll see your modulo rot 13 and raise with a exclusive or... > > -=-=-=-=- > > import sys

Re: parse a string of parameters and values

2009-12-12 Thread John Machin
Steven D'Aprano REMOVE-THIS-cybersource.com.au> writes: > > On Sat, 12 Dec 2009 16:16:32 -0800, bsneddon wrote: > > > > I am going to read a text file that is an export from a control system. > > It has lines with information like > > > > base=1 name="first one" color=blue > > > > I would l

Re: parse a string of parameters and values

2009-12-12 Thread Steven D'Aprano
On Sat, 12 Dec 2009 16:16:32 -0800, bsneddon wrote: > I have a problem that I can come up with a brute force solution to solve > but it occurred to me that there may be an > "one-- and preferably only one --obvious way to do it". I'm not sure that "brute force" is the right description here. Gen

Re: Dangerous behavior of list(generator)

2009-12-12 Thread Ned Deily
In article , Ned Deily wrote: > In article > , > Benjamin Kaplan wrote: > > On Sat, Dec 12, 2009 at 7:15 PM, Tom Machinski > > wrote: > > > In most cases, `list(generator)` works as expected. Thus, > > > `list()` is generally equivalent to `[ > > expression>]`. > > Actually, it's list(gener

Re: Dangerous behavior of list(generator)

2009-12-12 Thread Benjamin Kaplan
On Sat, Dec 12, 2009 at 9:01 PM, Ned Deily wrote: > In article > , >  Benjamin Kaplan wrote: >> On Sat, Dec 12, 2009 at 7:15 PM, Tom Machinski >> wrote: >> > In most cases, `list(generator)` works as expected. Thus, >> > `list()` is generally equivalent to `[> > expression>]`. >> Actually, it's

Re: Dangerous behavior of list(generator)

2009-12-12 Thread Ned Deily
In article , Benjamin Kaplan wrote: > On Sat, Dec 12, 2009 at 7:15 PM, Tom Machinski > wrote: > > In most cases, `list(generator)` works as expected. Thus, > > `list()` is generally equivalent to `[ > expression>]`. > Actually, it's list(generator) vs. a list comprehension. I agree that > it c

Re: parallelpython 1.5.7 crash

2009-12-12 Thread zeph
I looked in the browsable svn repo for parallel python at http://parallelpython.googlecode.com/svn/trunk/ 1) OverflowError: long int too large to convert to int This is a bug in their code (comments are mine) in pytransport.py: size_packed = self.r.read(struct.calcsize("!Q")) # reads in 8- char

Re: Dangerous behavior of list(generator)

2009-12-12 Thread Benjamin Kaplan
On Sat, Dec 12, 2009 at 7:15 PM, Tom Machinski wrote: > In most cases, `list(generator)` works as expected. Thus, > `list()` is generally equivalent to `[ expression>]`. > Actually, it's list(generator) vs. a list comprehension. I agree that it can be confusing, but Python considers them to be tw

Re: read text file byte by byte

2009-12-12 Thread Tim Chase
Steven D'Aprano wrote: 2) Should I use streams? What do you mean by "streams"? they're what come out of proton packs...just don't cross them. It would be bad. -tkc (I suspect the OP is a Java/C++ programmer where "streams" are somewhat akin to generators, but less powerful; so the answer

parse a string of parameters and values

2009-12-12 Thread bsneddon
I have a problem that I can come up with a brute force solution to solve but it occurred to me that there may be an "one-- and preferably only one --obvious way to do it". I am going to read a text file that is an export from a control system. It has lines with information like base=1 name="firs

Dangerous behavior of list(generator)

2009-12-12 Thread Tom Machinski
In most cases, `list(generator)` works as expected. Thus, `list()` is generally equivalent to `[]`. Here's a minimal case where this equivalence breaks, causing a serious and hard-to-detect bug in a program: >>> def sit(): raise StopIteration() ... >>> [f() for f in (lambda:1, sit, lambda:2

Re: Manipulating MySQL Sets

2009-12-12 Thread Carsten Haese
Victor Subervi wrote: > PS: > > Changed the code to this: > > elif col[:3] != 'pic': > if isinstance(colValue[0], (str, int, long, float, long, > complex, unicode, list, buffer, xrange, tuple)): > pass > else: > print 'XXX' >

Re: Manipulating MySQL Sets

2009-12-12 Thread MRAB
Victor Subervi wrote: On Sat, Dec 12, 2009 at 5:11 PM, Carsten Haese > wrote: Victor Subervi wrote: > Hi; > What type does python consider a MySQL Set?? Let's take a look: [snip] Looks like a string to me. Yep, sure does, but it isn't.

Re: Manipulating MySQL Sets

2009-12-12 Thread Carsten Haese
Victor Subervi wrote: > Yep, sure does, but it isn't. Again: > > if isinstance(colValue[0], (str, int, long, float, long, > complex, unicode, list, buffer, xrange, tuple)): > pass > else: > print 'XXX' > > and those "strings" printed tri

Re: Manipulating MySQL Sets

2009-12-12 Thread Victor Subervi
On Sat, Dec 12, 2009 at 6:07 PM, Victor Subervi wrote: > On Sat, Dec 12, 2009 at 5:11 PM, Carsten Haese wrote: > >> Victor Subervi wrote: >> > Hi; >> > What type does python consider a MySQL Set?? >> >> Let's take a look: >> >> >>> import MySQLdb >> >>> conn = MySQLdb.connect(db="carsten", user="b

Re: Manipulating MySQL Sets

2009-12-12 Thread Victor Subervi
On Sat, Dec 12, 2009 at 5:11 PM, Carsten Haese wrote: > Victor Subervi wrote: > > Hi; > > What type does python consider a MySQL Set?? > > Let's take a look: > > >>> import MySQLdb > >>> conn = MySQLdb.connect(db="carsten", user="blah", passwd="blah") > >>> cur = conn.cursor() > >>> cur.execute(""

Re: umath import error for Numpy builds on OSX 10.6

2009-12-12 Thread hardcoreUFO
On Dec 12, 5:44 pm, Robert Kern wrote: > On 2009-12-11 20:55 PM, hardcoreUFO wrote: > > > > > > > On Dec 11, 5:47 pm, Robert Kern  wrote: > > >> Right, when the -lnpymath stuff got checked in. Looking at the build log > >> you > >> posted to numpy-discusson, it does appear that the $LDFLAGS is >

Re: read text file byte by byte

2009-12-12 Thread Rhodri James
On Sat, 12 Dec 2009 11:14:13 -, census wrote: Steven D'Aprano wrote: On Sat, 12 Dec 2009 10:35:55 +0100, census wrote: I've got some questions - 1) How do I read the file byte by byte 2) Should I use streams? If so and I get my entire scrambled text in stream can I just write it to th

Re: Graph library for Python

2009-12-12 Thread geremy condra
On Thu, Dec 10, 2009 at 10:57 AM, Bearophile wrote: > Geremy Condra: > >> is there a particular way you want your attribution line to read? > > You can just use my nickname (in all lowercase), with the list of > parts you have used. Don't worry. > > >> Well, we all seem to have reinvented the whee

Re: Manipulating MySQL Sets

2009-12-12 Thread Carsten Haese
Victor Subervi wrote: > Hi; > What type does python consider a MySQL Set?? Let's take a look: >>> import MySQLdb >>> conn = MySQLdb.connect(db="carsten", user="blah", passwd="blah") >>> cur = conn.cursor() >>> cur.execute(""" ... create table pizza ( ... id integer, ... toppin

Manipulating MySQL Sets

2009-12-12 Thread Victor Subervi
Hi; What type does python consider a MySQL Set?? if isinstance(colValue[0], (str, int, long, float, long, complex, unicode, list, buffer, xrange, tuple)): pass else: print 'XXX' And the following fields pass through this net: Set and dat

Re: Moving from PHP to Python. Is it Possible

2009-12-12 Thread Tino Wildenhain
MRAB schrieb: > zeph wrote: > [snip] >> 4) It's better to collect all your eventual output into a string that >> you print - there are examples at [3]. You can import from other >> modules as needed (even conditionally), grow your string for output, >> then finally print it like (this example was a

Re: a list/re problem

2009-12-12 Thread Nobody
On Fri, 11 Dec 2009 12:49:42 -0800, Ed Keith wrote: > the following works: > > r = re.compile('\*(.+)\*') > > def f(s): > m = r.match(s) > if m: > return m.group(1) > else: > return '' > > n = [f(x) for x in l if r.match(x)] > > > > But it is inefficient, b

Re: power of explicit self?

2009-12-12 Thread Fire Crow
> It's not implemented in the compiler. There's a place in the runtime > for invoking a method where the object is inserted at the beginning > of the parameter list. IIRC, that's done by wrapping the function > object. This is the source of Objects/methodobject.c it look like this is where self is

Re: When will Python 3 be fully deployed

2009-12-12 Thread Martin v. Loewis
> In addition to Ned Deily's previous comments, I'd like to note that 2to3 > assumes the source is valid 2.6 code - you have to ensure the code runs > fine with Python 2.6 before using 2to3 to convert to 3.x That's wrong - 2to3 works just fine on, say, 2.3 code that has never been run on 2.6. Reg

Re: Python for simulating BRDF

2009-12-12 Thread Terry Reedy
Franky Frank wrote: I would like to write a simulation program using Python language for simulating bidirectional reflectance distribution function (BRDF) obtained from multi-angular remote sensing. I have a program written in C language. Can I convert it into Python language? Yes, but it wou

Re: Best way to conduct a google search

2009-12-12 Thread Terry Reedy
Daniel Dalton wrote: Hi, I need to do the following in my program: 1. Conduct a google search, supplying the variable "text" to the search. Is there a google api or something similar I should use? 2. I then need to be able to get the url, of the page, or the html content, so I can dump it to tex

Re: Getting Default Values Out of MySQL

2009-12-12 Thread Carsten Haese
Victor Subervi wrote: > > > On Sat, Dec 12, 2009 at 10:54 AM, Carsten Haese > wrote: > > Victor Subervi wrote: > > Hi; > > I'm using MySQLdb. If I do a > > cursor.execute('describe myTable;') > > it gives me all sorts of data but not my defaul

Re: Perl to Python conversion

2009-12-12 Thread Colin W.
On 09-Dec-09 15:33 PM, Martin Schöön wrote: First off: I am new here and this is my first post after lurking for quite some time. Second off: I don't know much Python---yet. Problem: I have come across a small open source application that I find quite useful. It does have one major flaw though.

Re: Getting Default Values Out of MySQL

2009-12-12 Thread Victor Subervi
On Sat, Dec 12, 2009 at 11:38 AM, MRAB wrote: > That's strange, I count 6! > > For example, the first field has the following columns: > >1. 'ID' > >2. 'tinyint(5) unsigned' > >3. 'NO' > >4. 'PRI' > >5. None > >6. 'auto_increment' Dunno why I counted 4 last time. Maybe c

Re: Getting Default Values Out of MySQL

2009-12-12 Thread MRAB
Victor Subervi wrote: On Sat, Dec 12, 2009 at 10:54 AM, Carsten Haese > wrote: Victor Subervi wrote: > Hi; > I'm using MySQLdb. If I do a > cursor.execute('describe myTable;') > it gives me all sorts of data but not my default values.

Re: a list/re problem

2009-12-12 Thread Lie Ryan
On 12/12/2009 8:24 AM, Peter Otten wrote: But it is inefficient, because it is matching the regex twice for each item, and it is a bit ugly. I could use: n = [] for x in keys: m = r.match(x) if m: n.append(m.group(1)) It is more efficient, but much uglier. It's

Re: Getting Default Values Out of MySQL

2009-12-12 Thread Victor Subervi
On Sat, Dec 12, 2009 at 10:54 AM, Carsten Haese wrote: > Victor Subervi wrote: > > Hi; > > I'm using MySQLdb. If I do a > > cursor.execute('describe myTable;') > > it gives me all sorts of data but not my default values. > > That function call doesn't "give" any data at all, except for the > rowco

Re: Getting Default Values Out of MySQL

2009-12-12 Thread Carsten Haese
Victor Subervi wrote: > Hi; > I'm using MySQLdb. If I do a > cursor.execute('describe myTable;') > it gives me all sorts of data but not my default values. That function call doesn't "give" any data at all, except for the rowcount (which would be the number of columns in the table). You must use s

Re: a list/re problem

2009-12-12 Thread Lie Ryan
import re r = re.compile('\*(.+)\*') def f(s): m = r.match(s) if m: return m.group(1) l = ['asc', '*nbh*', 'jlsdjfdk', 'ikjh', '*jkjsdfjasd*', 'rewr'] n = [y for y in (f(x) for x in l) if y] -- http://mail.python.org/mailman/listinfo/python-list

Re: Spawning an interactive interpreter in a running python process?

2009-12-12 Thread Lie Ryan
On 12/12/2009 3:49 PM, Tim Chase wrote: I'm curious, in an academic sense, if it's possible to spawn the interactive interpreter (>>>) in a running python application. Ideally, I would like to be able to access the modules, functions and variables the application can. Is something like this pos

Re: Problems with debugging Lists

2009-12-12 Thread Lie Ryan
On 12/12/2009 8:28 PM, Sancar Saran wrote: repr works as you say and I had some complaints, it wont format the output. Finding some string in 100 key dictionary in formatted in single line bit problematic. Is it any way to format it ? As has been mentioned, use pprint.pformat() to get what ppri

Getting Default Values Out of MySQL

2009-12-12 Thread Victor Subervi
Hi; I'm using MySQLdb. If I do a cursor.execute('describe myTable;') it gives me all sorts of data but not my default values. How do I retrieve them? TIA, Victor -- http://mail.python.org/mailman/listinfo/python-list

Python for simulating BRDF

2009-12-12 Thread Franky Frank
Dear python users, Greetings. I would like to write a simulation program using Python language for simulating bidirectional reflectance distribution function (BRDF) obtained from multi-angular remote sensing. I have a program written in C language. Can I convert it into Python language? In Python,

Re: MySQL set and enum, calling values

2009-12-12 Thread Carsten Haese
Victor Subervi wrote: > On Fri, Dec 11, 2009 at 8:13 PM, Gabriel Genellina > mailto:gagsl-...@yahoo.com.ar>> wrote: > Are you sure the column is declared as SET and not, say, VARCHAR? > > > yes Indeed it is, and knowing that, I can actually decode your original post. I apologize that I didn'

Re: power of explicit self?

2009-12-12 Thread John Roth
On Dec 11, 9:04 pm, Fire Crow wrote: > I'm looking for an explanation of how explicit self is implimented and > what features are only possible because of, or are greatly improved, > because of it. I've always liked explicit self and am looking for the > computer science behind it, so that I can e

Re: How to implement Varient/Tagged Unions/Pattern Matching in Python?

2009-12-12 Thread Kay Schluehr
> BTW, Please don't ask "Why do you want to do like this" No, I don't ask although it would be the interesting aspect for me ;) -- http://mail.python.org/mailman/listinfo/python-list

parallelpython 1.5.7 crash

2009-12-12 Thread makobu
Hi all, Hi all, with the above version of parallelpython, what causes this? Traceback (most recent call last): File "C:\Users\tim\code_base\svn\octopus\parallel_python\pp.py", line 762, in __run sresult = worker.t.receive() File "C:\Users\tim\code_base\svn\octopus\parallel_python \pptran

Re: Graph library for Python

2009-12-12 Thread Tiago de Paula Peixoto
On 12/10/2009 01:57 PM, Bearophile wrote: > Geremy Condra: >> Well, we all seem to have reinvented the wheel differently ;) > > Maybe also because they are designed for different purposes. This is true. For instance, the data structures and most algorithms in graph-tool are implemented in C++ to

pyserial - escape codes transportation

2009-12-12 Thread ObservantP
need help. newbie. pyserial and dot matrix printer. issue- escape codes arrive at printer ( verified from hex dump) but do not get applied. printer make/model STAR POS printer SP500. oddly, printer commands not initiated with the escape code .i.e. a symbol, work fine. import serial ser=serial.Se

Re: a list/re problem

2009-12-12 Thread Grant Edwards
On 2009-12-11, Neil Cerutti wrote: > On 2009-12-11, Grant Edwards wrote: >> [s[1:-1] for s in l if (s[0] == s[-1] == '*')] > > That last bit doesn't work right, does it, since an == expression > evaluates to True or False, no the true or false value itself? It works for me. Doesn't it work for

Re: a list/re problem

2009-12-12 Thread Neil Cerutti
On 2009-12-11, Grant Edwards wrote: > [s[1:-1] for s in l if (s[0] == s[-1] == '*')] That last bit doesn't work right, does it, since an == expression evaluates to True or False, no the true or false value itself? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Caps Lock State on Windows

2009-12-12 Thread census
N3wCr4Zy wrote: > how to i get Caps Lock state (on/off) on windows with win32api? public static extern short GetKeyState(int keyCode) in user32.dll -- http://mail.python.org/mailman/listinfo/python-list

Best way to conduct a google search

2009-12-12 Thread Daniel Dalton
Hi, I need to do the following in my program: 1. Conduct a google search, supplying the variable "text" to the search. Is there a google api or something similar I should use? 2. I then need to be able to get the url, of the page, or the html content, so I can dump it to text. Thanks, Dan signa

Re: Which graph library is best suited for large graphs?

2009-12-12 Thread Tiago de Paula Peixoto
Hi there, On 12/11/2009 08:12 AM, Wolodja Wentland wrote: > I really like the API of networkx but have no problem in switching to > another one (right now) I have the impression that graph-tool might > be faster and have a smaller memory footprint than networkx, but am > unsure about that. I

Re: When to use mechanize and Windmill library during WebScraping ?

2009-12-12 Thread Javier Collado
Hello, If a script that uses mechanize fails to find an html node that has been identified with Firebug, this is probably because that node has been autogenerated (provided that the expression to get the node is correct). As an alternative to verify this, you can try to download the html page and

Re: read text file byte by byte

2009-12-12 Thread census
Steven D'Aprano wrote: > On Sat, 12 Dec 2009 10:35:55 +0100, census wrote: > >>> I've got some questions - >>> 1) How do I read the file byte by byte 2) Should I use streams? If so >>> and I get my entire scrambled text in stream can I just write it to the >>> binary file? >>> >>> Thanks >>> Dave

Re: Spawning an interactive interpreter in a running python process?

2009-12-12 Thread Horace Blegg
Better and better! You know, I think I knew about those two, I just never connected the dots. With a little fiddling, I think I can cobble together what I want. My sincere thanks, sir/ma'am. On Fri, Dec 11, 2009 at 9:46 PM, Gabriel Genellina wrote: > En Sat, 12 Dec 2009 02:11:27 -0300, Horace Bl

Re: read text file byte by byte

2009-12-12 Thread Steven D'Aprano
On Fri, 11 Dec 2009 23:16:42 -0800, daved170 wrote: > Hello everybody, > I need to read a text file byte after byte. Eache byte is sent to a > function that scramble it and I need to write the result to binary file. > > I've got some questions - > 1) How do I read the file byte by byte f = open

Re: read text file byte by byte

2009-12-12 Thread Steven D'Aprano
On Sat, 12 Dec 2009 10:35:55 +0100, census wrote: >> I've got some questions - >> 1) How do I read the file byte by byte 2) Should I use streams? If so >> and I get my entire scrambled text in stream can I just write it to the >> binary file? >> >> Thanks >> Dave > > f = open ("binaryfile", "r")

Re: read text file byte by byte

2009-12-12 Thread census
daved170 wrote: > Hello everybody, > I need to read a text file byte after byte. > Eache byte is sent to a function that scramble it > and I need to write the result to binary file. > > I've got some questions - > 1) How do I read the file byte by byte > 2) Should I use streams? If so and I get my

Re: read text file byte by byte

2009-12-12 Thread census
daved170 wrote: > Hello everybody, > I need to read a text file byte after byte. > Eache byte is sent to a function that scramble it > and I need to write the result to binary file. > > I've got some questions - > 1) How do I read the file byte by byte > 2) Should I use streams? If so and I get my

Re: Problems with debugging Lists

2009-12-12 Thread Sancar Saran
On Saturday 12 December 2009 04:52:26 am Gabriel Genellina wrote: > En Fri, 11 Dec 2009 19:11:38 -0300, Sancar Saran > > escribió: > > In php we had print_r function to see entire array structure. After some > > search I found some equal module named pprint. > > > > And some how this module wont

Re: Open source projects

2009-12-12 Thread Daniel Fetchinson
>> I'm a pretty okay python programmer and I really want to start >> developing for an open source project. I'm looking for one that >> preferably deals with networking and isn't as huge as twisted (that's >> just a preference, not extremely important). Could anyone suggest any >> projects? I also

Python for simulating BRDF

2009-12-12 Thread Sharma, R.C.
Dear python users, Greetings. I would like to write a simulation program using Python language for simulating bidirectional reflectance distribution function (BRDF) obtained from multi-angular remote sensing. I have a program written in C language. Can I convert it into Python language? In Python,

Re: MySQL set and enum, calling values

2009-12-12 Thread Victor Subervi
On Fri, Dec 11, 2009 at 8:13 PM, Gabriel Genellina wrote: > En Fri, 11 Dec 2009 16:28:23 -0300, Victor Subervi < > victorsube...@gmail.com> escribió: > > On Fri, Dec 11, 2009 at 3:12 PM, Carsten Haese > >wrote: >> >> Victor Subervi wrote: >>> > [...] if I go to print, say, >>> > colFieldValues[2