Furius on-site Python training course

2006-04-14 Thread Martin Blais
Hello to all Python fiddlers and hackers! I thought I would send a short notice on this list about my Python training course offering. If you or people in your company would be interested in getting professional on-site Python training, I'm offering a 3-day intensive course on the Python language

Re: A question about the urllib2 ?

2006-04-14 Thread Bo Yang
Serge Orlov 写道: > Bo Yang wrote: > >> Hi , >> Recently I use python's urllib2 write a small script to login our >> university gateway . >> Usually , I must login into the gateway in order to surf the web . So , >> every time I >> start my computer , it is my first thing to do that open a browser

Re: VB to Python

2006-04-14 Thread Gregor Horvath
Aleksandar Cikota schrieb: > Can someone translate the VB code to Python? > > VB code: > > Dim chsr as New DriverHelper.Chooser > chsr.DeviceType = "Telescope" > scopeProgID = chsr.Choose(scopeProgID) > Set scope = CreateObject(scopeProgID) > scope.Connected = True > (untested; late binding):

Re: Help for a complete newbie

2006-04-14 Thread Ralph H. Stoos Jr.
Tim, After a little more research, I did find that out. It is funny, but in the tutorial "Non-Programmers Tutorial For Python", it makes no mention of the indentation issue, at least in the beginning portions which I had read. This is an age old problem of learning. Once you know something,

Re: Help for a complete newbie

2006-04-14 Thread Tim Roberts
"Ralph H. Stoos Jr." <[EMAIL PROTECTED]> wrote: > >I am reading a Python tutorial for complete non-programmers. > >The code below is so simple as to be insulting but the assignment of the >"ready" variable gives a syntax error. > >The code reads letter-for-letter like the tutorial states. Letter

Re: skip item in list "for loop"

2006-04-14 Thread Jacob Rael
Thanks for the suggestions. The solution I liked most was to prevent the lines from appearing in the first place!! -- http://mail.python.org/mailman/listinfo/python-list

Re: HELP PLEASE: What is wrong with this?

2006-04-14 Thread Steve Bergman
Welcome to Python! :-) You may find this mailing list useful: http://mail.python.org/mailman/listinfo/tutor -- http://mail.python.org/mailman/listinfo/python-list

Re: Help for a complete newbie

2006-04-14 Thread Steve Bergman
The indentation is wrong. Python cares about indentation. print " " print "This \"autotp\" program will create raw bitmap test pattern images." print " " print "Please read the information below thoroughly:" print " " print "1. Graphic files MUST be TIFF images." print "2. Images MUST have been

Re: Help for a complete newbie

2006-04-14 Thread John Machin
On 15/04/2006 12:04 PM, Ralph H. Stoos Jr. wrote: > All, > > I am reading a Python tutorial for complete non-programmers. Would you mind providing a URL for the tutorial? It's vaguely possible that we may be able to recommend a slightly better tutorial :-) > > The code below is so simple as to

Re: HELP PLEASE: What is wrong with this?

2006-04-14 Thread David Isaac
"Ralph H. Stoos Jr." <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > HELP PLEASE: What is wrong with this?File "autotp.py", line 21 > ready = raw_input("Ready to proceed ? TYPE (y)es or (n)o: ") > ^ Probably the parenthesis you forgot to close on the preceding line ... C

HELP PLEASE: What is wrong with this?

2006-04-14 Thread Ralph H. Stoos Jr.
File "autotp.py", line 21 ready = raw_input("Ready to proceed ? TYPE (y)es or (n)o: ") ^ -- http://mail.python.org/mailman/listinfo/python-list

Help for a complete newbie

2006-04-14 Thread Ralph H. Stoos Jr.
All, I am reading a Python tutorial for complete non-programmers. The code below is so simple as to be insulting but the assignment of the "ready" variable gives a syntax error. The code reads letter-for-letter like the tutorial states. Here is a dump. Can anyone tell me what is wrong? *

Re: Help with python output redirection

2006-04-14 Thread Steven D'Aprano
On Fri, 14 Apr 2006 16:59:13 -0700, fatalserpent wrote: > Here is the basic code (yes, I know its tiny). > > x = ['print "x =", x', 'for m in x: print m'] > print "x =", x > for m in x: print m > > I want to modify this so it will output to a file called 1. What I want > is to have that file dir

Re: python to c API, passing a tuple array

2006-04-14 Thread Farshid Lashkari
[EMAIL PROTECTED] wrote: > Hi, > I want to pass something like this to a C function via the Python C > API. > mytuple = (("string_one", 1.2, 1.3), ("string_two", 1.4, 1.5), .., > ., ) > This tuple is dynamic in size, it needs to be 3 X N dimensions. each > tuple in the > tuple array is of

Re: ping

2006-04-14 Thread Luis Armendariz
david brochu jr wrote: > Thanks, > > Unfortunately substituting os.system with os.popen results in the output > being: > > http://www.google.com/> > ', mode 'r' at 0x009C4650> > http://www.boston.com/> > ', mode 'r' at 0x009C4650> > http://www.espn.com/> > ', mode 'r' at 0x009C4650> > http://www

RE: ping

2006-04-14 Thread brandon.mcginty
Title: Message Try this: import os pinginfo=os.popen("ping www.google.com") #opens file object with output of the ping to google print pinginfo.read(-1) #reads the ping information from the abuv file object pinginfo.close() #closes the pinginfo object, as you would do for a standard file

Re: Writing backwards compatible code

2006-04-14 Thread James Stroud
Steven D'Aprano wrote: > I came across an interesting (as in the Chinese curse) problem today. I > had to modify a piece of code using generator expressions written with > Python 2.4 in mind to run under version 2.3, but I wanted the code to > continue to use the generator expression if possible. >

Re: ping

2006-04-14 Thread David Reed
On Apr 14, 2006, at 8:04 PM, david brochu jr wrote: > Thanks, > > Unfortunately substituting os.system with os.popen results in the > output being: > > ', mode 'r' at 0x009C4650> > ', mode 'r' at 0x009C4650> > ', mode 'r' at 0x009C4650> > ', mode 'r' at 0x009C4650> > > instead of giving me

Re: Problem involving sets...

2006-04-14 Thread Kent Johnson
flamesrock wrote: > Kind of a fun but confusing problem... > > I have two lists. Each list contains elements of two-element lists. > l1 = [['c1',1],['c2',2],['c3',4]] > l2 = [['c1',1],['c2',2],['c4',4],['c3',3]] > > Exactly in this format, where > superlist[0][0] is always a string > superlist[0]

Re: PEP 359: The "make" Statement

2006-04-14 Thread Tim Hochberg
Steven Bethard wrote: > Steven Bethard wrote: > >>Tim Hochberg wrote: >> >>>Steven Bethard wrote: >>> Steven Bethard wrote: >Duncan Booth wrote: > >>make Element html: >> make Element body: >> make Element p: >> text('But this ') >>

re: ping

2006-04-14 Thread david brochu jr
Thanks,   Unfortunately substituting os.system with os.popen results in the output being: www.google.com', mode 'r' at 0x009C4650> www.boston.com', mode 'r' at 0x009C4650> www.espn.com', mode 'r' at 0x009C4650> www.redsox.com', mode 'r' at 0x009C4650>  instead of giving me the ping stats "pinging

Help with python output redirection

2006-04-14 Thread fatalserpent
Here is the basic code (yes, I know its tiny). x = ['print "x =", x', 'for m in x: print m'] print "x =", x for m in x: print m I want to modify this so it will output to a file called 1. What I want is to have that file direct its output to a file called 2 and 2 direct to 3 and so on. Hopefully

Re: Should I learn Python instead?

2006-04-14 Thread Serge Orlov
fyleow wrote: > Hi guys, > > I'm a student/hobbyist programmer interested in creating a web project. > It's nothing too complicated, I would like to get data from an RSS > feed and store that into a database. I want my website to get the > information from the database and display parts of it dep

python to c API, passing a tuple array

2006-04-14 Thread imdognuts
Hi, I want to pass something like this to a C function via the Python C API. mytuple = (("string_one", 1.2, 1.3), ("string_two", 1.4, 1.5), .., ., ) This tuple is dynamic in size, it needs to be 3 X N dimensions. each tuple in the tuple array is of the form (string, float, float) as descri

Re: Problem involving sets...

2006-04-14 Thread Felipe Almeida Lessa
Em Sex, 2006-04-14 às 15:43 -0700, flamesrock escreveu: > Does anyone have a simple solution $ python2.4 Python 2.4.3 (#2, Mar 30 2006, 21:52:26) [GCC 4.0.3 (Debian 4.0.3-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> l1 = [['c1',1],['c2',2],['c3',4]]

Re: Should I learn Python instead?

2006-04-14 Thread ej
"fyleow" <[EMAIL PROTECTED]> wrote : > I realize that learning the library is part of the process, but as a > beginner I appreciate simplicity. > Is Python easier than C#? Absolutely. > Can someone show how to access an XML document on the web and have it ready > to be manipulated for comparis

Re: ping

2006-04-14 Thread David Reed
On Apr 14, 2006, at 6:30 PM, david brochu jr wrote: > I am trying to ping websites and output the results to a txt file: > > import os > > file = open("c:\python24\scripts\ip.txt") > redirect = open("c:\python24\scripts\log.txt","a") > > for x in file: > ping = "ping " + x > print >> redirect,

Problem involving sets...

2006-04-14 Thread flamesrock
Kind of a fun but confusing problem... I have two lists. Each list contains elements of two-element lists. l1 = [['c1',1],['c2',2],['c3',4]] l2 = [['c1',1],['c2',2],['c4',4],['c3',3]] Exactly in this format, where superlist[0][0] is always a string superlist[0][1] is always an integer Now what I

Re: Fixing Python instalation in win2000 by hand

2006-04-14 Thread BartlebyScrivener
>> I'll try from C: but. Definitely do that. None of the .msi installers are working for me from any drive except C. Been that way for months. Here's some helpful tips from an ActiveState email of a few months back. Note especially that you need version 2.0 or greater of the installer: Here

ping

2006-04-14 Thread david brochu jr
I am trying to ping websites and output the results to a txt file:   import os file = open("c:\python24\scripts\ip.txt")redirect = open("c:\python24\scripts\log.txt","a") for x in file: ping = "ping " + x print >> redirect, os.system(ping)  but the results seen in the log.txt file are:  

VB to Python

2006-04-14 Thread Aleksandar Cikota
Hi all, Can someone translate the VB code to Python? VB code: Dim chsr as New DriverHelper.Chooser chsr.DeviceType = "Telescope" scopeProgID = chsr.Choose(scopeProgID) Set scope = CreateObject(scopeProgID) scope.Connected = True For your prompt reply, I say thank you in advance. Best regards

Re: News-retrieval client-news.google

2006-04-14 Thread Matt H
[EMAIL PROTECTED] wrote: > Hi All, > I'm trying to write a news retrieval client in python. > I'm going to get the news from google's news service. > However, when I run the following code, google gives me a 403 error. Knowing google, they're blocking the user agent supplied by urllib2. -- http:/

Re: Should I learn Python instead?

2006-04-14 Thread Luis M. González
First of all, let me tell you that you can now write apps for .NET with Python. There's a python implementation for the .NET framework called Ironpython (in beta 5 now). Regarding XML, I can't tell you much but in general, python is much easier, cleaner, concise and intuitive than all the other al

Re: requestion regarding regular expression

2006-04-14 Thread BartlebyScrivener
This is very helpful. I wasn't the OP. I'm just learning, but I'm on the verge of making my own file searching scripts. This will be a huge help. Thanks for posting, and especially thanks for the comments in the code. Big help! rick -- http://mail.python.org/mailman/listinfo/python-list

Re: nested functions

2006-04-14 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, "Thomas Bartkus" <[EMAIL PROTECTED]> wrote: >Your function 'a' is it's own little world where functions 'b' and 'c' >exist. >Your code inside 'a' can call 'b' or 'c' - neat as you please. > >BUT 'b' and 'c' simply do not exist outside the 'a' world. It's worth dis

Re: Passing a packed C structure to a c module

2006-04-14 Thread Philippe Martin
I'll take a look, thanks. Jay Parlar wrote: > > On Apr 14, 2006, at 9:44 AM, Philippe Martin wrote: > >> Thanks, >> >> It's a pretty big structure: painfull to pass each item as a param. >> >> Regards, >> >> Philippe >> > > Maybe this can do something for you? > > http://pyconstruct.source

Re: Passing a packed C structure to a c module

2006-04-14 Thread Philippe Martin
I misslead you: it is a smart card-style ioctl ... Philippe "Martin v. Löwis" wrote: > Philippe Martin wrote: >> The call actually is an IOCtl: depending on the control code, the >> structure has a different format. > > Ah. In that case, I recommend to use the ioctl module; you won't need a >

Re: PEP 359: The "make" Statement

2006-04-14 Thread Steven Bethard
Steven Bethard wrote: > Tim Hochberg wrote: >> Steven Bethard wrote: >>> Steven Bethard wrote: Duncan Booth wrote: > make Element html: >make Element body: >make Element p: >text('But this ') >make Element strong: > te

Including standalone="no" in XML declaration

2006-04-14 Thread sdb1031
I'm trying to learn about Python and XML. I would like to be able to add standalone="no" to my xml declaration when writing an xml file, but I am unable to figure out how. So far, I have the following code: import xml.dom.minidom doc2 = xml.dom.minidom.Document() print doc2.toxml('iso-8859-1')

Should I learn Python instead?

2006-04-14 Thread fyleow
Hi guys, I'm a student/hobbyist programmer interested in creating a web project. It's nothing too complicated, I would like to get data from an RSS feed and store that into a database. I want my website to get the information from the database and display parts of it depending on the criteria I

Re: reading files in small chunks?

2006-04-14 Thread Rajesh Sathyamoorthy
Hi,What chunk sizes do you normally use in your code?Thank You.On 4/14/06, Amit Khemka <[EMAIL PROTECTED] > wrote:On 4/14/06, Rajesh Sathyamoorthy < [EMAIL PROTECTED]> wrote:> Hi,>> I wanted to know why it is more efficient to read a file in smaller chunks (> using file() or open() )? If this is no

Re: requestion regarding regular expression

2006-04-14 Thread Scott David Daniels
BartlebyScrivener wrote: > That's it. Thank you! Very instructive. > > Final: > > path = "d:/emacs files/emacsinit.txt" > lines = open(path).readlines() > # next two lines all on one > starts = [i for i, line in enumerate(lines) if > line.startswith('(defun')] > for i, start in enumerate(starts):

Re: skip item in list "for loop"

2006-04-14 Thread Diez B. Roggisch
Felipe Almeida Lessa schrieb: > Em Sex, 2006-04-14 às 20:33 +0200, Diez B. Roggisch escreveu: >> def read_lines(inFile): >> fg = iter(inFile) >> for line in fg: >> if "pmos4_highv" in line: >> fg.next() >> else: >> yield line > > Just be aware

Re: Unicode, command-line and idle

2006-04-14 Thread Kent Johnson
Egon Frerich wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > What do you have in the IDLE options - General - Default source encoding? UTF-8 > > Egon > > Kent Johnson schrieb am 12.04.2006 12:40: > >> [EMAIL PROTECTED] wrote: >>> Hello again, I've investigated a little bit and th

Re: PEP 359: The "make" Statement

2006-04-14 Thread Steven Bethard
Tim Hochberg wrote: > Steven Bethard wrote: >> Steven Bethard wrote: >>> Duncan Booth wrote: make Element html: make Element body: make Element p: text('But this ') make Element strong: text('could') text(

Re: list.clear() missing?!?

2006-04-14 Thread Ville Vainio
Duncan Booth wrote: > Looking in the 'obvious' place in the Tutorial, section 5.1 'More on > Lists' I found in the immediately following section 5.2 'The del > statement': I read the tutorial 6 years ago, and don't read it regularly. What's in the tutorial is not really important, what can be eas

Re: PEP 359: The "make" Statement

2006-04-14 Thread Tim Hochberg
Steven Bethard wrote: > Steven Bethard wrote: > >>Duncan Booth wrote: >> >>>Steven Bethard wrote: >>> >>> Should users of the make statement be able to determine in which dict object the code is executed? The make statement could look for a ``__make_dict__`` attribute and call it to a

Re: PEP 359: The "make" Statement

2006-04-14 Thread Steven Bethard
Rob Williscroft wrote: > Steven Bethard wrote in news:[EMAIL PROTECTED] > in comp.lang.python: > >> Open Issues >> === >> >> Does the ``make`` keyword break too much code? Originally, the make >> statement used the keyword ``create`` (a suggestion due to Nick >> Coghlan). However, inves

News-retrieval client-news.google

2006-04-14 Thread brandon.mcginty
Hi All, I'm trying to write a news retrieval client in python. I'm going to get the news from google's news service. However, when I run the following code, google gives me a 403 error. Is it google, or urllib2? Or is it the code? I can parse the 'contents' variable, I just need to know what is goi

Re: Passing a packed C structure to a c module

2006-04-14 Thread Martin v. Löwis
Philippe Martin wrote: > The call actually is an IOCtl: depending on the control code, the structure > has a different format. Ah. In that case, I recommend to use the ioctl module; you won't need a C wrapper, then. > Although the number of control codes/structures is finite, it would make the >

Re: Passing a packed C structure to a c module

2006-04-14 Thread Jay Parlar
On Apr 14, 2006, at 9:44 AM, Philippe Martin wrote: > Thanks, > > It's a pretty big structure: painfull to pass each item as a param. > > Regards, > > Philippe > Maybe this can do something for you? http://pyconstruct.sourceforge.net/ Jay P. -- http://mail.python.org/mailman/listinfo/python

Re: Writing backwards compatible code

2006-04-14 Thread Jack Diederich
On Sat, Apr 15, 2006 at 04:04:44AM +1000, Steven D'Aprano wrote: > I came across an interesting (as in the Chinese curse) problem today. I > had to modify a piece of code using generator expressions written with > Python 2.4 in mind to run under version 2.3, but I wanted the code to > continue to u

Re: Writing backwards compatible code

2006-04-14 Thread Felipe Almeida Lessa
Em Sex, 2006-04-14 às 13:37 -0500, Robert Kern escreveu: > Felipe Almeida Lessa wrote: > > Em Sex, 2006-04-14 às 13:28 -0500, Robert Kern escreveu: > > > >>Steven D'Aprano wrote: > >> > >>>I came across an interesting (as in the Chinese curse) problem today. I > >>>had to modify a piece of code us

Re: skip item in list "for loop"

2006-04-14 Thread Felipe Almeida Lessa
Em Sex, 2006-04-14 às 20:33 +0200, Diez B. Roggisch escreveu: > def read_lines(inFile): > fg = iter(inFile) > for line in fg: > if "pmos4_highv" in line: > fg.next() > else: > yield line Just be aware that the "fb.next()" line can raise an Stop

Re: Writing backwards compatible code

2006-04-14 Thread Robert Kern
Felipe Almeida Lessa wrote: > Em Sex, 2006-04-14 às 13:28 -0500, Robert Kern escreveu: > >>Steven D'Aprano wrote: >> >>>I came across an interesting (as in the Chinese curse) problem today. I >>>had to modify a piece of code using generator expressions written with >>>Python 2.4 in mind to run und

Re: Writing backwards compatible code

2006-04-14 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > What techniques do others use? I'd just write the generator with a yield statement. The generator expression does the same thing more concisely, I think. -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing backwards compatible code

2006-04-14 Thread Felipe Almeida Lessa
Em Sex, 2006-04-14 às 13:28 -0500, Robert Kern escreveu: > Steven D'Aprano wrote: > > I came across an interesting (as in the Chinese curse) problem today. I > > had to modify a piece of code using generator expressions written with > > Python 2.4 in mind to run under version 2.3, but I wanted the

Re: skip item in list "for loop"

2006-04-14 Thread Diez B. Roggisch
Jacob Rael schrieb: > I am new to python and I love it. I am hacking a file. I want to not > print a line if it contains the word 'pmos4_highv'. I also don't want > to print the next line. The following code works but it "smells bad" > and just doesn't look right. I was reading about generators. If

Re: Writing backwards compatible code

2006-04-14 Thread Robert Kern
Steven D'Aprano wrote: > I came across an interesting (as in the Chinese curse) problem today. I > had to modify a piece of code using generator expressions written with > Python 2.4 in mind to run under version 2.3, but I wanted the code to > continue to use the generator expression if possible.

Re: Kross - Start of a Unified Scripting Approach

2006-04-14 Thread has
Cool. I hope I got the bits about Kross right; I only just found out about it from seeing your post so haven't been long learning about it (I'm a sucker for this stuff). Hopefully some nice expert can correct anything I may've got wrong. :) BTW, if you're curious about how Python hooks into this s

Re: instance variable weirdness

2006-04-14 Thread Felipe Almeida Lessa
Em Sáb, 2006-04-15 às 04:03 +1000, Steven D'Aprano escreveu: > Sometimes you want the default to mutate each time it is used, for example > that is a good technique for caching a result: > > def fact(n, _cache=[1, 1, 2]): > "Iterative factorial with a cache." > try: > return _cache

Re: ftp connection and commands (directroy size, etc)

2006-04-14 Thread Stefan Schwarzer
Hi Arne On 2006-04-12 18:05, Arne wrote: > I am working on Windows XP and I want to do the following: > > 1. Connecting to a server using ftp > 2. Getting the directory structure and the size of each directory in the > root > 3. Getting the owner of a file > > All these steps I want to do with

Re: Fixing Python instalation in win2000 by hand

2006-04-14 Thread Sambo
BartlebyScrivener wrote: >>>Not sure if the .msi installers were broken before, >>>but they are now (on this installation) > > > Are you installing from c:\ ? almost never > > With administrator rights? > pretty sure "YES" > Check other requirements. It chokes if you are installing from anothe

skip item in list "for loop"

2006-04-14 Thread Jacob Rael
I am new to python and I love it. I am hacking a file. I want to not print a line if it contains the word 'pmos4_highv'. I also don't want to print the next line. The following code works but it "smells bad" and just doesn't look right. I was reading about generators. If I was using one, I could do

Writing backwards compatible code

2006-04-14 Thread Steven D'Aprano
I came across an interesting (as in the Chinese curse) problem today. I had to modify a piece of code using generator expressions written with Python 2.4 in mind to run under version 2.3, but I wanted the code to continue to use the generator expression if possible. My first approach was to use a

Re: instance variable weirdness

2006-04-14 Thread Steven D'Aprano
On Fri, 14 Apr 2006 13:30:49 -0300, Felipe Almeida Lessa wrote: > Em Sex, 2006-04-14 às 09:18 -0700, wietse escreveu: >> def __init__(self, name, collection=[]): > > Never, ever, use the default as a list. Unless you want to use the default as a list. Sometimes you want the default to mutat

Re: Python editing with emacs/wordstar key bindings.

2006-04-14 Thread [EMAIL PROTECTED]
This is new to me. I did not know that emacs HAD a word star mode. I may have to look at emacs again (last time was 1995). I am still looking for a python editor I like. Yes I used to write asm code in wordstar in nondocument mode. And yes all of the old dos editors used the wordstar keys. Eve

Re: Future Warning with Negative Int

2006-04-14 Thread Peter Otten
[EMAIL PROTECTED] wrote: > If I try to print a negative integer as a hexadecimal, I get the > following error: print "%X" % -1 > __main__:1: FutureWarning: %u/%o/%x/%X of negative int will return a > signed string in Python 2.4 and up > > > Does that mean that in the future it will

Re: Passing a packed C structure to a c module

2006-04-14 Thread Philippe Martin
Well, The call actually is an IOCtl: depending on the control code, the structure has a different format. Although the number of control codes/structures is finite, it would make the wrapper function fairly large. You seem to think that building the structure from python would be a mistake: why

Re: nested functions

2006-04-14 Thread bruno at modulix
Szabolcs Berecz wrote: > On 14 Apr 2006 04:37:54 -0700, [EMAIL PROTECTED] > <[EMAIL PROTECTED]> wrote: > >>def a(): >> def b(): >>print "b" >> def c(): >>print "c" >> >>how can i call c() ?? > > > Function c() is not meant to be called from outside function a(). > That's what a nested

Re: Fixing Python instalation in win2000 by hand

2006-04-14 Thread BartlebyScrivener
>> Not sure if the .msi installers were broken before, >> but they are now (on this installation) Are you installing from c:\ ? With administrator rights? Check other requirements. It chokes if you are installing from another logical drive, e.g., d:\ http://aspn.activestate.com/ASPN/docs/Active

Re: Passing a packed C structure to a c module

2006-04-14 Thread Martin v. Löwis
Philippe Martin wrote: > It's a pretty big structure: painfull to pass each item as a param. So how else would you like to pass them? Define the API you want, and then just implement it. It still shouldn't require to define the layout in Python. Regards, Martin -- http://mail.python.org/mailman/

Re: PEP 359: The "make" Statement

2006-04-14 Thread Nicolas Fleury
Felipe Almeida Lessa wrote: > Em Sex, 2006-04-14 às 09:31 -0600, Steven Bethard escreveu: >> [1] Here's the code I used to test it. >> >> >>> def make(callable, name, args, block_string): >> ... try: >> ... make_dict = callable.__make_dict__ >> ... except AttributeError: >> ...

Re: Forms with multiple submit buttons vs 'form' objects with single 'submit' methods

2006-04-14 Thread neil . fitzgerald
Paul Rubin wrote: > [EMAIL PROTECTED] writes: > > Here's my question: Suppose a form has more than one submit button. > > Now the COM 'form' object has a 'submit' method that doesn't take any > > arguments, so how do I tell it which button I want to press? > > What difference does it make? Don'

Re: PEP 359: The "make" Statement

2006-04-14 Thread Rob Williscroft
Steven Bethard wrote in news:[EMAIL PROTECTED] in comp.lang.python: > Open Issues > === > > Does the ``make`` keyword break too much code? Originally, the make > statement used the keyword ``create`` (a suggestion due to Nick > Coghlan). However, investigations into the standard librar

Re: Passing a packed C structure to a c module

2006-04-14 Thread Philippe Martin
Thanks, It's a pretty big structure: painfull to pass each item as a param. Regards, Philippe "Martin v. Löwis" wrote: > Philippe Martin wrote: >> Is it possible to define a packed C structure in python and pass it to >> the c module, or should the wrapper do that ? > > You can create a pack

Re: instance variable weirdness

2006-04-14 Thread Felipe Almeida Lessa
Em Sex, 2006-04-14 às 13:30 -0300, Felipe Almeida Lessa escreveu: > To solve your problem, change > def __init__(self, name, collection=[]): > BaseClass.__init__(self) > self.name = name > self.collection = collection # Will reuse the list > to > def __init__(self,

Re: instance variable weirdness

2006-04-14 Thread Felipe Almeida Lessa
Em Sex, 2006-04-14 às 09:18 -0700, wietse escreveu: > def __init__(self, name, collection=[]): Never, ever, use the default as a list. > self.collection = collection This will just make a reference of self.collection to the collection argument. > inst.collection.append(i) A

Fixing Python instalation in win2000 by hand

2006-04-14 Thread Sambo
Some time ago I bought a newer computer with W2000 already on it so I moved my old drive to it as secondary( python was installed on non primary partition ). Not sure if the .msi installers were broken before, but they are now (on this installation) and the reason I can't move to brand new instal

Re: requestion regarding regular expression

2006-04-14 Thread BartlebyScrivener
That's it. Thank you! Very instructive. Final: path = "d:/emacs files/emacsinit.txt" lines = open(path).readlines() # next two lines all on one starts = [i for i, line in enumerate(lines) if line.startswith('(defun')] for i, start in enumerate(starts): while start > 0 and lines[start-1].start

Re: Passing a packed C structure to a c module

2006-04-14 Thread Martin v. Löwis
Philippe Martin wrote: > Is it possible to define a packed C structure in python and pass it to the c > module, or should the wrapper do that ? You can create a packed structure using string concatenation, and with the help of the struct module. However, this gives you a string object in the end,

instance variable weirdness

2006-04-14 Thread wietse
Hello, I have written the following script to illustrate a problem in my code: class BaseClass(object): def __init__(self): self.collection = [] class MyClass(BaseClass): def __init__(self, name, collection=[]): BaseClass.__init__(self) self.name = name se

Passing a packed C structure to a c module

2006-04-14 Thread Philippe Martin
Hi, Is it possible to define a packed C structure in python and pass it to the c module, or should the wrapper do that ? Regards, Philippe -- http://mail.python.org/mailman/listinfo/python-list

Re: list.clear() missing?!?

2006-04-14 Thread Steven D'Aprano
Raymond, I suspect we're not seeing eye to eye on this issue, but I do appreciate you taking the time and effort. Thank you. My comments follow. On Thu, 13 Apr 2006 09:34:46 -0700, Raymond Hettinger wrote: > Both the pros and cons > were quipped with abrupt perjoratives so the bullet points could

">>>" and "..." (WAS PEP 359: The "make" Statement)

2006-04-14 Thread Steven Bethard
Felipe Almeida Lessa wrote: > Em Sex, 2006-04-14 às 09:31 -0600, Steven Bethard escreveu: >> [1] Here's the code I used to test it. >> >> >>> def make(callable, name, args, block_string): >> ... try: >> ... make_dict = callable.__make_dict__ >> ... except AttributeError: >>

Including standalone="no" in XML declaration

2006-04-14 Thread Stephen Briley
I'm trying to learn about Python and XML.  I would like to be able to add standalone="no" to my xml declaration when writing an xml file, but I am unable to figure out how.  So far, I have the following code: import xml.dom.minidom doc2 = xml.dom.minidom.Document() print doc2.toxml('iso-8859-1')

Re: requestion regarding regular expression

2006-04-14 Thread Kent Johnson
BartlebyScrivener wrote: > Kent, > > Running > > path = "d:/emacs files/emacsinit.txt" > lines = open(path).readlines() > # my defun lines are lowercase, > # next two lines are all on one > starts = [i for i, line in enumerate(lines) if > line.startswith('(defun')] > for i, start in starts: >

Re: zlib and zip files

2006-04-14 Thread Jan Prochazka
Felipe Almeida Lessa napsal(a): >Em Sex, 2006-04-14 às 17:14 +0200, Jan Prochazka escreveu: > > >>Here is my module for parsing zip files: >> >> > >1) Have you checked the source of Python's zipfile module? > > Nice, i thought, that zipfile is written in C, it should be possible to solve

Re: PEP 359: The "make" Statement

2006-04-14 Thread Felipe Almeida Lessa
Em Sex, 2006-04-14 às 09:31 -0600, Steven Bethard escreveu: > [1] Here's the code I used to test it. > > >>> def make(callable, name, args, block_string): > ... try: > ... make_dict = callable.__make_dict__ > ... except AttributeError: > ... make_dict = dict > ... bloc

Re: Python editing with emacs/wordstar key bindings.

2006-04-14 Thread BartlebyScrivener
Yes, thanks. I was just going to reinstall anyway. That usually fixes it. Rick -- http://mail.python.org/mailman/listinfo/python-list

Re: jpype and zxJDBC

2006-04-14 Thread benchline
I haven't compared them, and you may be exacly right. Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 359: The "make" Statement

2006-04-14 Thread Steven Bethard
Steven Bethard wrote: > Duncan Booth wrote: >> Steven Bethard wrote: >> >>> Should users of the make statement be able to determine in which dict >>> object the code is executed? The make statement could look for a >>> ``__make_dict__`` attribute and call it to allow things like:: >>> >>> mak

Re: Loop with float increments (frange)?

2006-04-14 Thread Tim Peters
[EMAIL PROTECTED] >> what's the standard way for a "for" loop with float increments? [Dan Sommers] > Use a while loop instead: > > f = initial_value > while f <= final_value: > process(f) > f = f + increment > > Note that there is no general guarantee that f will actually b

Re: Iterating command switches from a data file - have a working solution but it seems inefficient

2006-04-14 Thread Larry Bates
News wrote: > Hi everyone, > > My goal is to pull command switches/options from a file and then assign > the values to select variables which would eventually be included in a > class object. > > The data file looks something like this but the switches could be in any > order and not all may be u

Re: zlib and zip files

2006-04-14 Thread Felipe Almeida Lessa
Em Sex, 2006-04-14 às 17:14 +0200, Jan Prochazka escreveu: > Here is my module for parsing zip files: 1) Have you checked the source of Python's zipfile module? > import struct, zlib > > class ZipHeaderEntry: > name = '' > offset = 0 > uncomlen = 0 > comlen = 0 2) You know that

Re: zlib and zip files

2006-04-14 Thread Jan Prochazka
Michael Ekstrand napsal(a): > Jan Prochazka wrote: > >> Hi, >> I need to decompress zip archive. I wrote a parser of zip file, i obtain >> the compressed data, but when i call zlib.decompress(data) on them, >> it throws this error: >> >> decbuf = decompressor.decompress(compressed_data) >> >> erro

Re: requestion regarding regular expression

2006-04-14 Thread Felipe Almeida Lessa
Em Sex, 2006-04-14 às 07:47 -0700, BartlebyScrivener escreveu: > starts = [i for i, line in enumerate(lines) if > line.startswith('(defun')] This line makes a list of integers. enumerate gives you a generator that yields tuples consisting of (integer, object), and by "i for i, line" you unpack the

Re: requestion regarding regular expression

2006-04-14 Thread BartlebyScrivener
Kent, Running path = "d:/emacs files/emacsinit.txt" lines = open(path).readlines() # my defun lines are lowercase, # next two lines are all on one starts = [i for i, line in enumerate(lines) if line.startswith('(defun')] for i, start in starts: while start > 0 and lines[start-1].startswith(';

Re: zlib and zip files

2006-04-14 Thread Michael Ekstrand
Jan Prochazka wrote: > Hi, > I need to decompress zip archive. I wrote a parser of zip file, i obtain > the compressed data, but when i call zlib.decompress(data) on them, > it throws this error: > > decbuf = decompressor.decompress(compressed_data) > > error: Error -3 while decompressing: unknow

Embedding python and multiple separate scripts

2006-04-14 Thread Stefan D
Hi, I'm trying to embed python into an chat bot I've made in c++. After googling around and reading docs for almost a day I have a few questions. First of all it seems like the best way to be able to run separate scripts in different, isolated environments is to create a sub-interpreter (by us

  1   2   >