Python as an extension language

2006-03-06 Thread Torsten Bronger
Hallöchen! I'd like to use Python as an extension language for a C++ program. I.e., the user starts my program and gives a python script, either by file name or via stdin. The python script triggers a couple of function calls within the C++ program, and afterwards my program exits. I already kno

Re: Python version of XMLUnit?

2006-03-06 Thread Benjamin Niemann
Kent Johnson wrote: > I have found XMLUnit to be very helpful for testing Java and Jython code > that generates XML. At its heart XMLUnit is an XML-aware diff - it > parses expected and actual XML and pinpoints any differences. It is > smart enough to ignore things like attribute order, different

vb dll

2006-03-06 Thread Luca
Hello at all. I have to use a vb dll called ndxComm.dll I have do this but i get the following error: from win32com import client from win32com.client import Dispatch avatar = Dispatch("NdxComm") avatar.Reset(1, 20, True) pywintypes.com_error:(-2147221005, "s

Re: Setting timeout for read api

2006-03-06 Thread David Schwartz
"Paul Rubin" wrote in message news:[EMAIL PROTECTED] > "Swaroop" <[EMAIL PROTECTED]> writes: >> PLS HELP..I am working on socket programming as part of my final year >> project. I want to know how to set a timeout on read api that reads >> from a socket. Is it possibl

Re: raw strings and \

2006-03-06 Thread Blackbird
Slightly OT, but here is a crazy little program that shows the power of using raw strings: s=r'print "s=r\'%s\'\n%s"%(s,s)' print "s=r\'%s\'\n%s"%(s,s) When run, this program will print an exact copy of itself. Blackbird -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding method at runtime - problem with self

2006-03-06 Thread marek . rocki
Thank you all for your responses. That's exactly what I needed to know - how to bind a function to an object so that it would comply with standard calling syntax. This is largely a theoretical issue; I just wanted to improve my understanding of Python's OOP model. Using such features in real life

Re: Tix Note Book

2006-03-06 Thread Martin Franklin
[EMAIL PROTECTED] wrote: > hi > > am using Tix notebook and i have two frames in that. am adding some > widgets in to both of the frames. now i want to delete all of the > widgets in one of the frame. i dont want to delete the frame, but its > childres. > so how can i get the sub widgets within th

Suggesting the use of StandardError as base of error Exceptions.

2006-03-06 Thread Antoon Pardon
In a number of cases I have a program that looks like the following. for case in all_cases: try: treat(case) except Exception, ErrInfo: generate_traceback() The idea is to get as much information as possible when something goes wrong but at the same time treat as many cases as possibl

Re: Why I chose Python over Ruby

2006-03-06 Thread Bil Kleb
Xavier Morel wrote: > >> 2) Ruby does not have true first-class functions living in the same >> namespace as other variables while Python does : >> >> In Ruby you need extra syntax that ruins the "first-class-ness" : >> > The extra syntax is a side-effect of the parensless call of method, it > doe

Re: Why I chose Python over Ruby

2006-03-06 Thread Xavier Morel
Bil Kleb wrote: > Xavier Morel wrote: >>> 2) Ruby does not have true first-class functions living in the same >>> namespace as other variables while Python does : >>> >>> In Ruby you need extra syntax that ruins the "first-class-ness" : >>> >> The extra syntax is a side-effect of the parensless cal

Re: how do you move to a new line in your text editor?

2006-03-06 Thread Fabio Zadrozny
Which indenting features do you find missing? Note: 1.0.3 -- still unreleased -- has implemented if / elif /else auto unindent... Jorge Godoy wrote: >Mc Osten <[EMAIL PROTECTED]> writes: > > > >>Because I tried it and it just lacks a lot of functionality you get with >>TextMate or Emacs. It is

Re: Package organization: where to put 'common' modules?

2006-03-06 Thread Paul Boddie
fortepianissimo wrote: > Paul Boddie wrote: > > fortepianissimo wrote: > > > Hm this doesn't work. Say I have the following directory structure: > > > > > > A > > > |--- util > > > ||--- foo.py > > > | > > > |--- B > > > |--- bar.py > > > > > > > > > And bar.py has this line > > > > > > fr

Re: Python as an extension language

2006-03-06 Thread Sybren Stuvel
Torsten Bronger enlightened us with: > I already know how to do that in principle. My only concern is > distributing the thing, especially for the Windows platform. Check out distutils and py2exe. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment

Re: Python advocacy in scientific computation

2006-03-06 Thread Magnus Lycka
Dennis Lee Bieber wrote: > I did look at Ruby once... It looked to me like the worst aspects of > PERL grafted onto the worst parts of old Python. Don't forget that there are portions of Smalltalk syntax (blocks) added in as well. I guess it could be seen as Perl-NG. Both the name 'Ruby' and

Re: django and mod_python

2006-03-06 Thread Laurent Rahuel
Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a écrit : >> Hi, >> >> I read the mod_python documentation on the Django site but I'm getting >> this error: >> >> EnvironmentError: Could not import DJANGO_SETTINGS_MODULE >> 'accesshiphop.settings' (is it on sys.path?): No module named >> accesshi

Re: Separating elements from a list according to preceding element

2006-03-06 Thread Rob Cowie
Thanks everyone. I assumed there was something I had not considered... list slicing is that thing. The pyParsing example looks interesting - but for this case, a little too heavy. It doesn't really warrant including a third party module. Rob C -- http://mail.python.org/mailman/listinfo/python-l

Re: Python as an extension language

2006-03-06 Thread Torsten Bronger
Hallöchen! Sybren Stuvel <[EMAIL PROTECTED]> writes: > Torsten Bronger enlightened us with: > >> I already know how to do that in principle. My only concern is >> distributing the thing, especially for the Windows platform. > > Check out distutils and py2exe. I know that py2exe can convert a Py

Re: how do you move to a new line in your text editor?

2006-03-06 Thread Jorge Godoy
Fabio Zadrozny <[EMAIL PROTECTED]> writes: > Which indenting features do you find missing? Note: 1.0.3 -- still unreleased > -- has implemented if / elif /else auto unindent... The most basic one is not having my code moving forward with sucessive TABs pressed. When I press TAB on Emacs it use a

Re: Suggesting the use of StandardError as base of error Exceptions.

2006-03-06 Thread Diez B. Roggisch
Antoon Pardon schrieb: > In a number of cases I have a program that looks like the following. > > for case in all_cases: > try: > treat(case) > except Exception, ErrInfo: > generate_traceback() > > The idea is to get as much information as possible when something > goes wrong but at t

Re: Write a GUI for a python script?

2006-03-06 Thread paron
If you are already familiar with html, you might consider using the browser for the UI. It's pretty much cross-platform, if you ever need that, and users are accustomed to browser look/feel. If your installation doesn't already have a python-enabled http server running, there are several options (

Re: raw strings and \

2006-03-06 Thread Steven D'Aprano
Almost off-topic. Well, okay, completely off-topic. On Sun, 05 Mar 2006 19:47:07 -0800, plahey wrote: > I would say that a foolish anything is something to avoid. I don't > think that anyone would claim that inconsistency is a virtue in a > computer language (or in anything else for that matter

Re: spliting on ":"

2006-03-06 Thread fileexit
> yyy > yyy > yyy > xxx.xxx.xxx.xxx > xxx.xxx.xxx.xxx of course you will get this result... inside the loop, when line="xxx.xxx.xxx.xxx:yyy" line.split(":") will give a list ["xxx.xxx.xxx.xxx", "yyy"], and element -1 will be "yyy" but when line="xxx.xxx.xxx.xxx" line.split(":") will give a list

Re: raw strings and \

2006-03-06 Thread Fredrik Lundh
"Blackbird" <[EMAIL PROTECTED]> wrote: > Slightly OT, but here is a crazy little program that shows the power of > using raw strings: > > s=r'print "s=r\'%s\'\n%s"%(s,s)' > print "s=r\'%s\'\n%s"%(s,s) > > When run, this program will print an exact copy of itself. I'm not sure what the raw strings

Re: Python as an extension language

2006-03-06 Thread Miki Tebeka
Hello Torsten, > I'd like to use Python as an extension language for a C++ program. > I.e., the user starts my program and gives a python script, either > by file name or via stdin. The python script triggers a couple of > function calls within the C++ program, and afterwards my program > exits.

Re: Python version of XMLUnit?

2006-03-06 Thread Kent Johnson
Benjamin Niemann wrote: > http://www.logilab.org/projects/xmldiff > > You'd still have to integrate this into your test framework though... Thanks, that looks promising. > > And I'll have a look at XMLUnit - seem's like something I could use for my > current project ;) XMLUnit is *very* useful.

Re: Popup menus without an associated window

2006-03-06 Thread Miki Tebeka
Hello Rich, > Is there a way using any of the Python UI toolkits to generate popup > menus outside the context of an application? For example, > middle-clicking on the desktop shows a list of shortcuts to choose > from. > > Pointers to source examples would be appreciated. wxPython: import wx

Re: Suggesting the use of StandardError as base of error Exceptions.

2006-03-06 Thread Kent Johnson
Diez B. Roggisch wrote: > Antoon Pardon schrieb: >> Now I was wondering if it wouldn't be better that for exception >> that indicate some error condition that these would inherit >> from StandardError and that this would be indicated in the >> documentation and reflected in the stdlib? >> >> Would

Re: Why I chose Python over Ruby

2006-03-06 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Bil Kleb <[EMAIL PROTECTED]> wrote: > The parensless calls also allow one to write beautiful > DSLs with Ruby. What's a DSL? -- http://mail.python.org/mailman/listinfo/python-list

a good algo to do this

2006-03-06 Thread eight02645999
hi i need to do something like this eg given a number (as a string) = "123" there are a few combination i want to find with this string, ie "132","321","231","312" and "213". so there are 6 combinations altogether. i remember there's a formula for this, but forgot. Does python have any modules/func

Re: Why I chose Python over Ruby

2006-03-06 Thread Marcin Mielżyński
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, > Bil Kleb <[EMAIL PROTECTED]> wrote: > >> The parensless calls also allow one to write beautiful >> DSLs with Ruby. > > What's a DSL? Domain Specific Language. It is easy to tweak Rubys syntax and semantics into something that looks like anot

Re: raw strings and \

2006-03-06 Thread Blackbird
Fredrik Lundh wrote: > "Blackbird" <[EMAIL PROTECTED]> wrote: > >> Slightly OT, but here is a crazy little program that shows the power >> of using raw strings: >> >> s=r'print "s=r\'%s\'\n%s"%(s,s)' >> print "s=r\'%s\'\n%s"%(s,s) >> >> When run, this program will print an exact copy of itself. > >

Re: a good algo to do this

2006-03-06 Thread drochom
hi, try this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465 cheers. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why I chose Python over Ruby

2006-03-06 Thread Bil Kleb
Marcin Mielżyński wrote: > Roy Smith wrote: > >> What's a DSL? > > Domain Specific Language. It is easy to tweak Rubys syntax and semantics > into something that looks like another language designed for a specific > task. For example, see Margin Fowler's articles: http://martinfowler.com/bli

Re: Python advocacy in scientific computation

2006-03-06 Thread Bil Kleb
Magnus Lycka wrote: > Dennis Lee Bieber wrote: > >> I did look at Ruby once... It looked to me like the worst aspects of >> PERL grafted onto the worst parts of old Python. > > Don't forget that there are portions of Smalltalk syntax > (blocks) added in as well. I guess it could be seen as Pe

Re: Why I chose Python over Ruby

2006-03-06 Thread Torsten Bronger
Hallöchen! Marcin Mielżyński <[EMAIL PROTECTED]> writes: > Roy Smith wrote: > >> In article <[EMAIL PROTECTED]>, >> Bil Kleb <[EMAIL PROTECTED]> wrote: >> >>> The parensless calls also allow one to write beautiful DSLs with >>> Ruby. >> >> What's a DSL? > > Domain Specific Language. It is easy t

Re: vb dll

2006-03-06 Thread Luca
I have solve Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: django and mod_python

2006-03-06 Thread bruno at modulix
Laurent Rahuel wrote: > Bruno Desthuilliers wrote: > > >>[EMAIL PROTECTED] a écrit : >> >>>Hi, >>> >>>I read the mod_python documentation on the Django site but I'm getting >>>this error: >>> >>>EnvironmentError: Could not import DJANGO_SETTINGS_MODULE >>>'accesshiphop.settings' (is it on sys.pat

Re: Adding method at runtime - problem with self

2006-03-06 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > Thank you all for your responses. That's exactly what I needed to know > - how to bind a function to an object so that it would comply with > standard calling syntax. > > This is largely a theoretical issue; I just wanted to improve my > understanding of Python's OOP mod

Re: Incorrect Decimal-Float behaviour in comparison tests

2006-03-06 Thread Magnus Lycka
Sergei Organov wrote: > Well, without reading the manuals I'd expect this to raise an exception > instead of yielding of meaningless and confusing result, consider: Without reading the manuals, you can only expect that Python will be "compatible" with the ideas you have of things based on previous

Re: Cryptographically random numbers

2006-03-06 Thread Bryan Olson
Tuvas wrote: > Okay, I'm working on devoloping a simple, cryptographically secure > number, from a range of numbers (As one might do for finding large > numbers, to test if they are prime). My function looks like this: > > def cran_rand(min,max): > if(min>max): > x=max > max=mi

help with loops

2006-03-06 Thread Catalina Scott A Contr AFCA/EVEO
Hello,   I am not having luck writing code to do what I want and could use a hand.   I have two files and I want to pull out lines from file 2 if certain conditions are found if file 1.     for line in readfile1:     list1 = line.split(',')     for line in readfile2:     li

Re: slicing the end of a string in a list

2006-03-06 Thread John Salerno
Paul Rubin wrote: > John Salerno <[EMAIL PROTECTED]> writes: >> Interesting. So I would say: >> >> [line.rstrip() for line in open('C:\\switches.txt')] How would I manually close a file that's been opened this way? Or is it not possible in this case? Is it necessary? -- http://mail.python.org/m

processing the genetic code with python?

2006-03-06 Thread nuttydevil
I have many notepad documents that all contain long chunks of genetic code. They look something like this: atggctaaactgaccaagcgcatgcgtgttatccgcgagaaagttgatgcaaccaaacag tacgacatcaacgaagctatcgcactgctgaaagagctggcgactgctaaattcgtagaa agcgtggacgtagctgttaacctcggcatcgacgctcgtaaatctgaccagaacgtacgt ggtgcaac

Re: a good algo to do this

2006-03-06 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > hi > i need to do something like this > eg given a number (as a string) = "123" > there are a few combination i want to find with this string, ie > "132","321","231","312" and "213". so there are 6 combinations > altogether. i remember there's a formula for this, but for

Re: raw strings and \

2006-03-06 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I guess my point is that it is quite surprising that r'\' is not a > legal way to represent a backslash. I look for consistency in the > tools that I work with and this except-for-the-last-character exception > is annoying you seem to be missing that "exception" you th

Re: Python advocacy in scientific computation

2006-03-06 Thread Tim Hochberg
Magnus Lycka wrote: > Dennis Lee Bieber wrote: [SNIP] > >> For CPU-bound number-crunching, perhaps... For I/O-bound jobs, the >>GIL is(should be) released when ever a thread is blocked waiting for I/O >>to complete. > > > I think CPU-bound number-crunching was the big deal in this case. > S

Re: help with loops

2006-03-06 Thread Tim Chase
> I have two files and I want to pull out lines from file 2 > if certain conditions are found if file 1. Well, I'm not quite sure from your description of the problem if you want to compare every line in file1 against every line in file2, or if you just want to compare line1 of file1 with line

Re: how do you move to a new line in your text editor?

2006-03-06 Thread Fabio Zadrozny
Ok, I'm putting those in my 'todo-list' ;-) -- keep an eye open for future releases... Cheers, Fabio Jorge Godoy wrote: >Fabio Zadrozny <[EMAIL PROTECTED]> writes: > > > >>Which indenting features do you find missing? Note: 1.0.3 -- still unreleased >>-- has implemented if / elif /else auto

Re: Random Prime Generator/Modular Arithmetic

2006-03-06 Thread Bryan Olson
Tuvas wrote: > Okay, now I get the correct number of 561 pseudoprimes, 5, so I can > assume that it is indeed working right. Your code now looks right, so I'm guessing "5" was a typo, perhaps because "5" is just below "8" on the numeric keypad. You can simplify your loop like: def is_strong_pse

Re: processing the genetic code with python?

2006-03-06 Thread Diez B. Roggisch
nuttydevil schrieb: > I've tried various ways of doing this but keep coming unstuck along the > way. Has anyone got any suggestions for how they would tackle this > problem? > Thanks for any help recieved! Show us your ways, show us where you got stuck - then we'd might be able to help you. Diez

RE: help with loops

2006-03-06 Thread Catalina Scott A Contr AFCA/EVEO
I was trying to compare each line of file1 with each line of file2. Your solution worked perfectly. Thanks! Scott -Original Message- From: Tim Chase [mailto:[EMAIL PROTECTED] Sent: Monday, March 06, 2006 9:17 AM To: Catalina Scott A Contr AFCA/EVEO Cc: [email protected] Subject: R

Re: Outdated Python Info on www.unicode.org

2006-03-06 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, Dennis Benzinger <[EMAIL PROTECTED]> wrote: > Could someone who knows the current state of Unicode support in Python > update this information? I've just passed this along to the folks at the Unicode Consortium. Dave -- http://mail.python.org/mailman/listinfo/p

Simulation Programming Skills and Python

2006-03-06 Thread Richard Blackwood
Hello all. I have a few questions about simulation programming. One, do all programmers know to how to code a simulation? By simulation I mean a model of real world relationships (i.e. like Civilization which is a simulation of ruling nations through various historical settings). For example, c

Re: slicing the end of a string in a list

2006-03-06 Thread Steve Holden
John Salerno wrote: > Paul Rubin wrote: > >>John Salerno <[EMAIL PROTECTED]> writes: >> >>>Interesting. So I would say: >>> >>>[line.rstrip() for line in open('C:\\switches.txt')] > > > > How would I manually close a file that's been opened this way? Or is it > not possible in this case? Is it

Re: Suggesting the use of StandardError as base of error Exceptions.

2006-03-06 Thread Steven Bethard
Antoon Pardon wrote: > I then took a look at http://docs.python.org/lib/module-exceptions.html > which describes the exception heirarchy as follows: > > Exception > +-- SystemExit > +-- StopIteration > +-- StandardError > | + > | + All kind of error exceptions >

Re: Why I chose Python over Ruby

2006-03-06 Thread Xavier Morel
Torsten Bronger wrote: > Yes, however, this is also true for Python in my opinion. > Ruby's ability to generate DSLs is an order of magnitude better than Python's at least. I only know of the Lisp dialects that get better at DSLs. Check Rails' validation methods (in the models), or if you don't

RE: help with loops

2006-03-06 Thread Catalina Scott A Contr AFCA/EVEO
I sent that last email out too soon. It appeared to be working but it is only comparing the last line of file1 with all lines of file2. Any idea how to make this loop work to compare every line of file1 with every line of file2? for line1 in file1.readlines(): list1 = line1.split(",")

Re: processing the genetic code with python?

2006-03-06 Thread Steve Holden
Diez B. Roggisch wrote: > nuttydevil schrieb: > >>I've tried various ways of doing this but keep coming unstuck along the >>way. Has anyone got any suggestions for how they would tackle this >>problem? >>Thanks for any help recieved! > > > Show us your ways, show us where you got stuck - then we

Pyserial again

2006-03-06 Thread luca72
Hello I have solve the problem of configuration with pyserial but i have another question. The serial port close every time i make the read and re-open when i do i new write. In my script there is not write close , why it close ? Thaks Luca -- http://mail.python.org/mailman/listinfo/python-list

sys.stdin.readline() results in extra space send to stdout

2006-03-06 Thread Benjamin Rutt
There has been a problem that has been bugging me for a while for reading input from standard in. Consider the following simple program: #!/usr/bin/env python import sys print 'enter something: ', answer = sys.stdin.readline().strip() print 'you answered {%s}' % (answer) When

Re: processing the genetic code with python?

2006-03-06 Thread Roy Smith
In article <[EMAIL PROTECTED]>, nuttydevil <[EMAIL PROTECTED]> wrote: >I have many notepad documents that all contain long chunks of genetic >code. They look something like this: > >atggctaaactgaccaagcgcatgcgtgttatccgcgagaaagttgatgcaaccaaacag >tacgacatcaacgaagctatcgcactgctgaaagagctggcgactgctaaattcg

Re: how do you move to a new line in your text editor?

2006-03-06 Thread Xavier Morel
John Salerno wrote: > So I'm wondering, how do you all handle moving around in your code in > cases like this? Is there some sort of consistency to these things that > you can write rules for your text editor to know when to outdent? It > doesn't seem like you can do this reliably, though. Under

%r

2006-03-06 Thread Blackbird
I'm trying to get a complete grip on %r. Is it true that the two programs a = '*anything the parser accepts*' print '%r' % a vs. a = r'*anything the parser accepts*' print "'%s'" % a always produce the same output, where *anything the parser accepts* can be replaced with, well, anything the pa

Re: sys.stdin.readline() results in extra space send to stdout

2006-03-06 Thread Steve Holden
Benjamin Rutt wrote: > There has been a problem that has been bugging me for a while for > reading input from standard in. Consider the following simple program: > > #!/usr/bin/env python > import sys > print 'enter something: ', > answer = sys.stdin.readline().strip() > print

wanted: ftp server class

2006-03-06 Thread John Pote
Hi everyone, I have a 'client' with a built in ftp client that I wish to use to access a server via the internet. But I do not want to use a standard disk accessing ftp server as I need to do my own processing between the filesystem and the ftp TCP/IP port. Can someone suggest the source of a

Re: Why I chose Python over Ruby

2006-03-06 Thread Mystilleef
Simple, clarity! Ruby reads like Perl's younger cousin. -- http://mail.python.org/mailman/listinfo/python-list

Re: a good algo to do this

2006-03-06 Thread Gerard Flanagan
Gerard Flanagan wrote: > [EMAIL PROTECTED] wrote: > > hi > > i need to do something like this > > eg given a number (as a string) = "123" > > there are a few combination i want to find with this string, ie > > "132","321","231","312" and "213". so there are 6 combinations > > altogether. i remember

Re: Pyserial again

2006-03-06 Thread Grant Edwards
On 2006-03-06, luca72 <[EMAIL PROTECTED]> wrote: > I have solve the problem of configuration with pyserial but i > have another question. The serial port close every time i make > the read and re-open when i do i new write. I doubt it. > In my script there is not write close, why it close ? How

Re: Why I chose Python over Ruby

2006-03-06 Thread Torsten Bronger
Hallöchen! Xavier Morel <[EMAIL PROTECTED]> writes: > Torsten Bronger wrote: > >> Yes, however, this is also true for Python in my opinion. > > Ruby's ability to generate DSLs is an order of magnitude better > than Python's at least. If good DSL includes morphing into another language, this may

Re: %r

2006-03-06 Thread Duncan Booth
Blackbird wrote: > I'm trying to get a complete grip on %r. Is it true that the two > programs > > a = '*anything the parser accepts*' > print '%r' % a > > vs. > > a = r'*anything the parser accepts*' > print "'%s'" % a > > always produce the same output, where *anything the parser accepts*

Re: slicing the end of a string in a list

2006-03-06 Thread John Salerno
Steve Holden wrote: > It's not possible to perform an explicit close if, as in this case, you > don't have an explicit reference to the file object. > > In CPython it's not strictly necessary to close the file, but other > implementations don't guarantee that a file will be closed after the >

Re: Runtime Error when loading ".pyd" module

2006-03-06 Thread Terry Tang
Fredrik, Thanks, the information is very helpful, and I have resolved our problem. I was not aware that the .pyd files will load pythonNN.dll. Regards. -Terry - Original Message - From: "Fredrik Lundh" <[EMAIL PROTECTED]> To: Sent: Thursday, March 02, 2006 12:53 AM Subject: Re: Runti

Re: Pyserial again

2006-03-06 Thread Peter Hansen
luca72 wrote: > I have solve the problem of configuration with pyserial but i have > another question. > The serial port close every time i make the read and re-open when i do > i new write. Please describe what you are observing that makes you say that the port is closing. > In my script there

Need help initializing a list or tuple.

2006-03-06 Thread KraftDiner
I need a matrix of 256 x 256 unsigned short values... The matrix can be implemented as a list of lists or a tuple... So for example: [[1][2][3], [4][5][6], [7][8][9]] or ((1,2,3),(4,5,6), (7,8,9)) This is what I have so far but its not working... a = [][] for i in range(0,256): for j in r

Re: %r

2006-03-06 Thread Fredrik Lundh
"Blackbird" wrote: > I'm trying to get a complete grip on %r. Is it true that the two programs > > a = '*anything the parser accepts*' > print '%r' % a > > vs. > > a = r'*anything the parser accepts*' > print "'%s'" % a > > always produce the same output, where *anything the parser accepts* can be

Re: %r

2006-03-06 Thread Peter Hansen
Blackbird wrote: > I'm trying to get a complete grip on %r. Is it true that the two programs > > a = '*anything the parser accepts*' > print '%r' % a > > vs. > > a = r'*anything the parser accepts*' > print "'%s'" % a > > always produce the same output, where *anything the parser accepts* can

Re: Simulation Programming Skills and Python

2006-03-06 Thread Lonnie Princehouse
Object oriented languages lend themselves fairly well to this sort of modeling, and a strong programmer in any language should be able to take a good description of a well thought-out model and write some code for it. However, by far the harder part is designing a good model. Asking whether all p

Re: Need help initializing a list or tuple.

2006-03-06 Thread Fredrik Lundh
"KraftDiner" wrote: > I need a matrix of 256 x 256 unsigned short values... > The matrix can be implemented as a list of lists or a tuple... > So for example: > [[1][2][3], [4][5][6], [7][8][9]] > or > ((1,2,3),(4,5,6), (7,8,9)) > > This is what I have so far but its not working... > > a = [][] >

Re: spliting on ":"

2006-03-06 Thread Bryan Olson
Peter Hansen wrote: > The archives could tell you more, but basically on is usually interested > in *identity* with a singleton object (None), not in whether the object > on is examining happens to compare equal. A custom object could be > designed to compare equal to None in certain cases, eve

Re: %r

2006-03-06 Thread Blackbird
Duncan Booth wrote: > Blackbird wrote: > >> [...] > a = 'I don\'t think so' print '%r' % a > "I don't think so" a = r'I don\'t think so' print "'%s'" % a > 'I don\'t think so' Excellent counterexample. Can something like this happen for other things than quotes? -- http://m

Re: Simulation Programming Skills and Python

2006-03-06 Thread bearophileHUGS
Richard Blackwood: >Is the skill of being able to translate in one's head realworld relationships >into a model represented by code an inherent/native skill of all programmers?< I don't think so. Creating a good computational model can be a complex art. >Python a good language for simulation p

Re: Pyserial again

2006-03-06 Thread luca72
Hello here is a part of code, the values for settings comes from combo box: here i take the ATR of the smartcard inserted in the reader, and than i store the read data in a textctrl. Sniffing the data with serial port monitor i see that the answer is ok but after the answer the port close, why? An

Re: Simulation Programming Skills and Python

2006-03-06 Thread gene tani
Richard Blackwood wrote: > Hello all. I have a few questions about simulation programming. One, do > all programmers know to how to code a simulation? By simulation I mean a > model of real world relationships (i.e. like Civilization which is a > simulation of ruling nations through various histor

Re: %r

2006-03-06 Thread Fredrik Lundh
"Blackbird" <[EMAIL PROTECTED]> wrote: > >> [...] > > > a = 'I don\'t think so' > print '%r' % a > > "I don't think so" > a = r'I don\'t think so' > print "'%s'" % a > > 'I don\'t think so' > > Excellent counterexample. Can something like this happen for other things > than qu

Re: Simulation Programming Skills and Python

2006-03-06 Thread Richard Blackwood
Okay, I really like that analogy. Not everything a carpenter can do requires an architect to draw up a blueprint though. For example, if I tell a carpenter I want a tree house with built-in seating and a window in the roof, no other requirements, can't they figure out how to do that on their own? S

Re: Need help initializing a list or tuple.

2006-03-06 Thread KraftDiner
Thank you that worked great! a = [[None] * 256] * 256 for i in range(0,256): for j in range(0,256): a[i][j] = i**2 Now.. Can I change this quickly into a 1 dimensional list of length 65536? -- http://mail.python.org/mailman/listinfo/python-list

Re: spliting on ":"

2006-03-06 Thread Cyril Bazin
On 3/6/06, Bryan Olson <[EMAIL PROTECTED]> wrote: Peter Hansen wrote:> The archives could tell you more, but basically on is usually interested> in *identity* with a singleton object (None), not in whether the object> on is examining happens to compare equal.  A custom object could be > designed to

Re: Simulation Programming Skills and Python

2006-03-06 Thread Richard Blackwood
So I can't develop and code the model simultaneously if I'm relying on the programming skill of someone who doesn't understand what I'm modelling? Also, say I (the hypothetical expert of knowledge domain X) learn programming, an I necessarily going to know how to model X with programming? When you

Re: Pyserial again

2006-03-06 Thread Grant Edwards
On 2006-03-06, luca72 <[EMAIL PROTECTED]> wrote: > Hello here is a part of code, No. Wrong. The "part of code" you posted tells us nothing. We can not help you if you keep posting vague descriptions of what you imagine is wrong and small, out-of-context chunks of irrelevant code. **

copying a tuple to a list..

2006-03-06 Thread [EMAIL PROTECTED]
i have a result tuple from a MySQLdb call that would like to change in place.. i would like to copy it to a list, so i can modify it in place, but i cannot figure out how to do it. the result typle is dataResults and i thought i could do something like dataList = [] dataList = dataResults b

Re: Need help initializing a list or tuple.

2006-03-06 Thread Diez B. Roggisch
KraftDiner schrieb: > Thank you that worked great! > > a = [[None] * 256] * 256 > for i in range(0,256): > for j in range(0,256): > a[i][j] = i**2 > > Now.. Can I change this quickly into a 1 dimensional list of length > 65536? sum(a, []) Diez -- http://mail.python.org/ma

automatic referencing for variables?

2006-03-06 Thread [EMAIL PROTECTED]
i am SURE i am using the wrong terminology... but what i would like to do is something like this: pageContent=''' {toc} h1. Header Section h2. Date: {metadata:date}'''+date+'''{metatdata} h2. Author: {metadata:author}Len Sweet{metadata} h1. Exegesis {metadata:exegesis}'''+exegesis+'''{me

Re: processing the genetic code with python?

2006-03-06 Thread David E. Konerding DSD staff
In article <[EMAIL PROTECTED]>, nuttydevil wrote: > I have many notepad documents that all contain long chunks of genetic > code. They look something like this: > > atggctaaactgaccaagcgcatgcgtgttatccgcgagaaagttgatgcaaccaaacag > tacgacatcaacgaagctatcgcactgctgaaagagctggcgactgctaaattcgtagaa > agcgtgg

Re: Need help initializing a list or tuple.

2006-03-06 Thread KraftDiner
Strange behaviour... a = [[None] * 256] * 256 for i in range(0,256): for j in range(0,256): a[i][j] = i**2 a = sum(a, []) print a[0] print a[65535] Prints: 65025 65025 -- http://mail.python.org/mailman/listinfo/python-list

Re: Package organization: where to put 'common' modules?

2006-03-06 Thread fortepianissimo
Kent Johnson wrote: > Paul Boddie wrote: > > Yes, Python does this - it puts the directory of bar.py (B in this > > case) in sys.path, but not the directory in which you're sitting when > > you run the program from the shell (A in this case). > > This seems to be OS dependent. If I put 'print sys.

Re: automatic referencing for variables?

2006-03-06 Thread gene tani
[EMAIL PROTECTED] wrote: > i am SURE i am using the wrong terminology... > > but what i would like to do is something like this: > > pageContent=''' > {toc} > h1. Header Section > h2. Date: > {metadata:date}'''+date+'''{metatdata} > h2. Author: > {metadata:author}Len Sweet{metadata} > h1.

Re: automatic referencing for variables?

2006-03-06 Thread Rene Pijlman
[EMAIL PROTECTED]: >can you do something like that in python? All you did is show us some string literals, but I guess you're looking for string substitution: http://docs.python.org/lib/typesseq-strings.html This can be simplified, they say: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe

Re: Need help initializing a list or tuple.

2006-03-06 Thread Fredrik Lundh
"KraftDiner" wrote: > Strange behaviour... > > a = [[None] * 256] * 256 > for i in range(0,256): > for j in range(0,256): > a[i][j] = i**2 > a = sum(a, []) > print a[0] > print a[65535] > > Prints: > > 65025 > 65025 looks like you missed that the page I pointed you to explained *why* the a = [[No

Re: Argument Precedence (possible bug?)

2006-03-06 Thread vbgunz
Hello, Steven D'Aprano, Terry Jan Reedy! I would really like to extend my thanks to you guys. I hope I've got it right this time! def posKeyArgs(a, b=2, c=3): print a, b, c #posKeyArgs(b=20) # too few positional arguments. a needs an arg. #posKeyArgs(10, c=30, 20) # pos_args cannot follow

Fetch info from website and write to txt file.

2006-03-06 Thread Pitmairen
I want to make a program that get info from a website and prints it out in a txt file. I made this: import urllib f = urllib.urlopen("http://www.imdb.com/title/tt0407304/";) s = f.read() k = open("test.txt","w") k.write(s) k.close() f.close() That saves all the html code into the test.txt file.

  1   2   3   >