Re: importing modules question

2007-10-17 Thread warhero
got it figured out. nevermind. -- http://mail.python.org/mailman/listinfo/python-list

importing modules question

2007-10-17 Thread warhero
Hey all, sorry for the totally newb question. I recently switched over to python from ruby. I'm having problems figuring out how module importing works.. as a simple example I've got these files: /example/loader.py /example/loadee.py loadee.py class loadee(object): def __init__(self):

Re: Best Python Linux distribution

2007-10-17 Thread James Matthews
Redhat and now Oracle's Linux installer is written in python! They are all very good but watch for some programs that require legacy versions of library's like wx On 17 Oct 2007 23:10:33 -0700, Devraj <[EMAIL PROTECTED]> wrote: > > I would recommend a Debian based distribution like Ubuntu or Debia

Re: Last iteration?

2007-10-17 Thread Hendrik van Rooyen
"Raymond Hettinger" wrote: > More straight-forward version: > > def lastdetecter(iterable): > t, lookahead = tee(iterable) > lookahead.next() > return izip(chain(imap(itemgetter(0), izip(repeat(False), > lookahead)), repeat(True)), t) If this is what you call straightforward - heave

Re: Best Python Linux distribution

2007-10-17 Thread Devraj
I would recommend a Debian based distribution like Ubuntu or Debian itself :) On Oct 17, 10:29 pm, Anthony Perkins <[EMAIL PROTECTED]> wrote: > Hi everyone, > > What is the best GNU/Linux distribution (or the most preferred) for > developing Python applications? Ideally I would like one with both

Re: Noob questions about Python

2007-10-17 Thread Ixiaus
> Right idea: now to remove all those intermediate lists you construct. > 1. reversed(val) creates an iterator that runs over the elements (here > of a string) in reverse order. > 2. enumerate() is usually better than using an explicit list index. > 3. You can use a generator in your sum to avoid c

Re: Noob questions about Python

2007-10-17 Thread Michele Simionato
On Oct 17, 5:58 pm, Ixiaus <[EMAIL PROTECTED]> wrote: > def bin2dec(val): > li = list(val) > li.reverse() > res = [int(li[x])*2**x for x in range(len(li))] > print sum(res) > > It basically does the same thing int(string, 2) does. > > Thank you for the responses! BTW, here is the

Embedded Boost.Python Enum

2007-10-17 Thread Cory
Hi, I have a hopefully quick question about how to use Boost.Python to export an Enum. I am embedding python in C++ and am currently exporting my classes in the following way: nameSpace["OBJECT"] = class_("OBJECT") .def("getType", &OBJECT::getType) .def("setSprite", &OBJECT::setSp

Re: urlgrabber cookie handling?

2007-10-17 Thread Devraj
Hi John, Thanks for getting back to me. I did find the ASPN article. If I figure this out then I will make sure I post the code somewhere for public consumption. On Oct 18, 6:13 am, [EMAIL PROTECTED] (John J. Lee) wrote: > Devraj <[EMAIL PROTECTED]> writes: > > Hi everyone, > > > I have been batt

Re: Strange behaviour with reversed()

2007-10-17 Thread Andreas Kraemer
On Oct 17, 9:31 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > I don't understand how reversed() is operating. I've read the description > in the docs: > > reversed(seq) > Return a reverse iterator. seq must be an object which supports the > sequence protocol (the __len__() met

Re: Strange behaviour with reversed()

2007-10-17 Thread Gabriel Genellina
En Thu, 18 Oct 2007 01:31:13 -0300, Steven D'Aprano <[EMAIL PROTECTED]> escribió: > I don't understand how reversed() is operating. I've read the description > in the docs: > > reversed(seq) > Return a reverse iterator. seq must be an object which supports the > sequence protocol (the __len__()

Re: Noob questions about Python

2007-10-17 Thread George Sakkis
On Oct 17, 6:23 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Oct 17, 10:58 pm, Ixiaus <[EMAIL PROTECTED]> wrote: > > > > > Thank you for the quick responses. > > > I did not know that about integer literals beginning with a '0', so > > thank you for the explanation. I never really use PHP except

Re: Strange behaviour with reversed()

2007-10-17 Thread Ben Finney
Steven D'Aprano <[EMAIL PROTECTED]> writes: > and help(reversed) but neither gives any insight to what happens > when you use reversed() on a sequence, then modify the sequence. I would think the answer is the same for any question about modifying sequences while iterating: "undefined, therefore

Re: Elisp Tutorial: HTML Syntax Coloring Code Block

2007-10-17 Thread Ben Finney
Xah Lee <[EMAIL PROTECTED]> writes: > Elisp Tutorial: HTML Syntax Coloring Code Block Utterly irrelevant to most of the groups in the Newsgroups field. Followups set to comp.lang.lisp and comp.emacs only, please. -- \ "[The RIAA] have the patience to keep stomping. They're playing | `\

Script to Download Ubuntu Gutsy ASAP

2007-10-17 Thread danfolkes
I thought I would post the source to a program that I made that will download the http://ubuntu.media.mit.edu/ubuntu-releases/gutsy/ as soon as its posted. It checks the site every 10 min time.sleep(600) This is mostly untested so I would appreciate comments, and if you use it, post that too! :)

Re: Last iteration?

2007-10-17 Thread Paul Rubin
Raymond Hettinger <[EMAIL PROTECTED]> writes: > We need a C-speed verion of the lambda function, something like a K > combinator that consumes arguments and emits constants. Some discussion of this is at . I had suggested implementing K through an optional seco

Re: Python Labs Move

2007-10-17 Thread Gabriel Genellina
En Wed, 17 Oct 2007 19:46:47 -0300, Bill Garey <[EMAIL PROTECTED]> escribió: > What is PYTHON 2.2.1 and what does it do? I see the Program on my > list of programs but don't know how to use it , or what it is! See this FAQ entry: http://www.python.org/doc/faq/installed/ -- Gabriel Genel

Re: Bidirectional communication over unix socket (named pipe)

2007-10-17 Thread Raúl Gómez C.
This is the code I'm running (just the server): #!/usr/bin/python import socket import os, os.path import time if os.path.exists("hpcd_sock"): os.remove("hpcd_sock") server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) server.bind("hpcd_sock") while True: datagram = server.recv(10

Re: if instance exists problem ..

2007-10-17 Thread Gabriel Genellina
En Thu, 18 Oct 2007 00:07:34 -0300, Steven D'Aprano <[EMAIL PROTECTED]> escribió: > On Thu, 18 Oct 2007 03:00:56 +, Steven D'Aprano wrote: > >> On Wed, 17 Oct 2007 23:12:15 +, Paul Hankin wrote: >> >>> 'if x' doesn't test if x exists, it tests if x when cast to a bool is >>> True. >> >>

Re: Bidirectional communication over unix socket (named pipe)

2007-10-17 Thread Raúl Gómez C.
Nop, it doesn't work, at least for me (python 2.5)... On 10/18/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > > As I understand the OP's own response, changing SOCK_DGRAM to SOCK_STREAM > here solved the issue. > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/pytho

Re: Bidirectional communication over unix socket (named pipe)

2007-10-17 Thread Gabriel Genellina
En Wed, 17 Oct 2007 18:20:06 -0300, Raúl Gómez C. <[EMAIL PROTECTED]> escribió: > BTW: This is the original post: > > > server = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) As I understand the OP's own response, changing SOCK_DGRAM to SOCK_STREAM here solved the issue. -- Gabriel Genel

Strange behaviour with reversed()

2007-10-17 Thread Steven D'Aprano
I don't understand how reversed() is operating. I've read the description in the docs: reversed(seq) Return a reverse iterator. seq must be an object which supports the sequence protocol (the __len__() method and the __getitem__() method with integer arguments starting at 0). New in version 2.4

Re: Pull Last 3 Months

2007-10-17 Thread Gabriel Genellina
En Wed, 17 Oct 2007 21:47:50 -0300, Tim Chase <[EMAIL PROTECTED]> escribió: > In the event that you need them in whatever your locale is, you > can use the '%b' formatting to produce them: I prefer the calendar module in that case: py> import locale py> locale.setlocale(locale.LC_ALL, '') 'Spa

Re: Simple Text Processing Help

2007-10-17 Thread Tim Roberts
[EMAIL PROTECTED] wrote: > >And now for something completely different... > >I've been reading up a bit about Python and Excel and I quickly told >the program to output to Excel quite easily. However, what if the >input file were a Word document? I can't seem to find much >information about parsi

Elisp Tutorial: HTML Syntax Coloring Code Block

2007-10-17 Thread Xah Lee
Elisp Tutorial: HTML Syntax Coloring Code Block Xah Lee, 2007-10 This page shows a example of writing a emacs lisp function that process a block of text to syntax color it by HTML tags. If you don't know elisp, first take a gander at Emacs Lisp Basics. HTML version with color and links is at: ht

Re: Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Gabriel Genellina
En Wed, 17 Oct 2007 18:03:56 -0300, Debajit Adhikary <[EMAIL PROTECTED]> escribió: > What in general is a good way to learn about little things like these? > (I'm fairly new to the language) > > A google search for 'python list methods" did not turn up the + > operator anywhere for me. Where cou

Re: Need recommendations on mock object packages

2007-10-17 Thread Gabriel Genellina
En Wed, 17 Oct 2007 13:42:25 -0300, Matthew Wilson <[EMAIL PROTECTED]> escribió: > What are the most popular, easiest to use, and most powerful mock > object packages out there? mock libraries were discussed recently on this list, search the archives. I like minimock: http://blog.ianbicking.org

Re: Noob questions about Python

2007-10-17 Thread hg
Ixiaus wrote: > I have recently (today) just started learning/playing with Python. So > far I am excited and impressed (coming from PHP background). > > I have a few questions regarding Python behavior... > > val = 'string' > li = list(val) > print li.reverse() > > returns nothing, but, > > va

Re: if instance exists problem ..

2007-10-17 Thread Steven D'Aprano
On Thu, 18 Oct 2007 03:00:56 +, Steven D'Aprano wrote: > On Wed, 17 Oct 2007 23:12:15 +, Paul Hankin wrote: > >> 'if x' doesn't test if x exists, it tests if x when cast to a bool is >> True. > > To be pedantic: > > Python doesn't have type casts. bool(x) doesn't cast x as a bool, it >

Re: Write by logging.FileHandler to one file by many processess

2007-10-17 Thread Gabriel Genellina
En Wed, 17 Oct 2007 11:10:55 -0300, Diez B. Roggisch <[EMAIL PROTECTED]> escribió: >> On Oct 17, 3:33 pm, Rafa Zawadzki <[EMAIL PROTECTED]> wrote: >>> >>> As I saw in logging source - there is no lock per file during making >>> emit() (only lock per thread). >>> >>> So, my question is - is it s

Re: Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Steven D'Aprano
On Wed, 17 Oct 2007 21:40:40 +, Paul Hankin wrote: > On Oct 17, 10:03 pm, Debajit Adhikary <[EMAIL PROTECTED]> wrote: >> How does "a.extend(b)" compare with "a += b" when it comes to >> performance? Does a + b create a completely new list that it assigns >> back to a? If so, a.extend(b) would

Re: if instance exists problem ..

2007-10-17 Thread Steven D'Aprano
On Wed, 17 Oct 2007 23:12:15 +, Paul Hankin wrote: > 'if x' doesn't test if x exists, it tests if x when cast to a bool is > True. To be pedantic: Python doesn't have type casts. bool(x) doesn't cast x as a bool, it creates a brand new Boolean object from x. Also, the "if x" test looks at

Re: Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Steven D'Aprano
On Wed, 17 Oct 2007 23:46:25 +, Debajit Adhikary wrote: > On Oct 17, 5:40 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: >> To answer your question though: a += b is *not* the same as a = a + b. >> The latter would create a new list and assign it to a, whereas a += b >> updates a in-place. > > I

[Fwd: Re: why doesn't have this list a "reply-to" ?]

2007-10-17 Thread Colin J. Williams
Original Message Subject: Re: why doesn't have this list a "reply-to" ? Date: Wed, 17 Oct 2007 11:13:49 +0900 From: Byung-Hee HWANG <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] Organisation: InZealBomb To: python-list@python.org Newsgroups: gmane.comp.python.general Referenc

Re: Noob questions about Python

2007-10-17 Thread [EMAIL PROTECTED]
On Oct 17, 4:58 pm, Ixiaus <[EMAIL PROTECTED]> wrote: > Thank you for the quick responses. > > I did not know that about integer literals beginning with a '0', so > thank you for the explanation. I never really use PHP except for > handling basic forms and silly web stuff, this is why I picked up >

Re: Pull Last 3 Months

2007-10-17 Thread Ben Finney
John Machin <[EMAIL PROTECTED]> writes: > It's a bit hard to see how anybody could imagine that in the expression > [months[(month - i - 1) % 12] for i in range(n)] > the number 12 referred to anything but the number of months in a year. Exactly, that's what people *will* assume. But what if

Re: Python Labs Move

2007-10-17 Thread Terry Reedy
"Bill Garey" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] |What is PYTHON 2.2.1 and what does it do? It is the interpreter for the 2.2 version of the Python language. See the tutorial at python.org. | I see the Program on my list of programs but don't know how to use it , or

Re: Pull Last 3 Months

2007-10-17 Thread John Machin
On 18/10/2007 10:33 AM, Ben Finney wrote: > Paul Hankin <[EMAIL PROTECTED]> writes: > >> import datetime >> >> months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split() >> >> def last_months(n): >> month = datetime.date.today().month >> return [months[(month - i - 1) % 12] for i i

Re: Best way to generate alternate toggling values in a loop?

2007-10-17 Thread Grant Edwards
On 2007-10-17, Debajit Adhikary <[EMAIL PROTECTED]> wrote: > # Start of Code > > def evenOdd(): > values = ["Even", "Odd"] > state = 0 > while True: > yield values[state] > state = (state + 1) % 2 I'd replace the last line with state ^= 1 to save a

Re: why doesn't have this list a "reply-to" ?

2007-10-17 Thread Robert Kern
[david] wrote: > Steve Lamb wrote: >> On 2007-10-17, Byung-Hee HWANG <[EMAIL PROTECTED]> wrote: >>> Just click "Ctrl-L", then you can reply to lists directly if you use >>> good mailer like mutt or thunderbird or evolution ;; >> Thunderbird only if it has the list-reply patch, has either enigm

Re: Pull Last 3 Months

2007-10-17 Thread John Machin
On Oct 18, 8:56 am, Shane Geiger <[EMAIL PROTECTED]> wrote: > A simpler way, imho: > > import datetime > m = { > 1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun',7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} > > month = datetime.date.today().month > if month == 1: > ans = [m[11], m[12], m[

Re: why doesn't have this list a "reply-to" ?

2007-10-17 Thread [david]
Steve Lamb wrote: > On 2007-10-17, Byung-Hee HWANG <[EMAIL PROTECTED]> wrote: >> Just click "Ctrl-L", then you can reply to lists directly if you use >> good mailer like mutt or thunderbird or evolution ;; > > Thunderbird only if it has the list-reply patch, has either enigmail or > mhengy in

Re: CGI and external JavaScript nightmare

2007-10-17 Thread IamIan
Thank you for the replies. After a lot of research I tracked down the issue. I was using the CGI to build all of the pages for the site, then filling in content with .innerHTML= as users clicked on tabs. Since I wanted to place the Google Ads in different parts of each page, the Google Ads JavaScri

Re: Pull Last 3 Months

2007-10-17 Thread Ben Finney
Paul Hankin <[EMAIL PROTECTED]> writes: > import datetime > > months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split() > > def last_months(n): > month = datetime.date.today().month > return [months[(month - i - 1) % 12] for i in range(n)] > > print last_months(3) Heck you don

Re: Pull Last 3 Months

2007-10-17 Thread Tim Chase
> It looks like you copied the month 2 case from the month 1 case > because you forgot to edit it afterwards. Anyway, a bit of modulo-12 > arithmetic avoids special cases, and allows the number of months to be > generalised: nice... > import datetime > > months = 'Jan Feb Mar Apr May Jun Jul Aug

Re: Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Robert Kern
Debajit Adhikary wrote: > On Oct 17, 5:40 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: >> To answer your question though: a += b is *not* the same as a = a + b. >> The latter would create a new list and assign it to a, whereas a += b >> updates a in-place. > > I know I'm being a little finicky here,

Re: Best way to generate alternate toggling values in a loop?

2007-10-17 Thread Carsten Haese
On Wed, 2007-10-17 at 23:55 +, Debajit Adhikary wrote: > I'm writing this little Python program which will pull values from a > database and generate some XHTML. > > I'm generating a where I would like the alternate 's to be > > > and > > > What is the best way to do this? > > I wrote a

Re: Best Python Linux distribution

2007-10-17 Thread Anthony Perkins
- Original Message - From: "Anthony Perkins" <[EMAIL PROTECTED]> > What is the best GNU/Linux distribution (or the most preferred) for > developing Python applications? Thanks for your advice guys, the Debian 4.0r1 DVD (suggested off-list) seems to fit my needs best. -- Anthony Perki

Best way to generate alternate toggling values in a loop?

2007-10-17 Thread Debajit Adhikary
I'm writing this little Python program which will pull values from a database and generate some XHTML. I'm generating a where I would like the alternate 's to be and What is the best way to do this? I wrote a little generator (code snippet follows). Is there a better (more "Pythonic") way to

Re: if instance exists problem ..

2007-10-17 Thread Ben Finney
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > stef mientki schrieb: > > What should I do to the same simple test for existance ? > > Use isinstance(obj, type). No, that's *far* more specific than "does it exist", and will give false negatives. Much better is:: foo = None foo = do_so

Re: Pull Last 3 Months

2007-10-17 Thread Paul Hankin
On Oct 17, 11:56 pm, Shane Geiger <[EMAIL PROTECTED]> wrote: > A simpler way, imho: > > import datetime > m = { > 1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun',7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} > > month = datetime.date.today().month > if month == 1: > ans = [m[11], m[12], m

Re: Async XMLRPC and job processing

2007-10-17 Thread Adonis Vargas
Sean Davis wrote: > I would like to set up a server that takes XMLRPC requests and > processes them asynchronously. The XMLRPC server part is trivial in > python. The job processing part is the part that I am having trouble > with. I have been looking at how to use threadpool, but I can't see >

Re: Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Debajit Adhikary
On Oct 17, 5:40 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > To answer your question though: a += b is *not* the same as a = a + b. > The latter would create a new list and assign it to a, whereas a += b > updates a in-place. I know I'm being a little finicky here, but how would someone know that

Re: if instance exists problem ..

2007-10-17 Thread Diez B. Roggisch
stef mientki schrieb: > hello, > > I've written a convenience wrapper around ConfigObj (which is a imporved > ConfigParser). > > Now if I use an instance of the base class, I can easily test is the > instance exists by " if ini:", > like in this example > >ini = None >if ini: >

Re: if instance exists problem ..

2007-10-17 Thread Paul Hankin
On Oct 17, 11:39 pm, stef mientki <[EMAIL PROTECTED]> wrote: > the test if an instance exists, always returns false. > ini = inifile (filename) > if ini: > print 'ok',type(ini) > else: > print 'wrong',type(ini) > > Why is that ? > What should I do to the same simple test

Re: CGI and external JavaScript nightmare

2007-10-17 Thread allen.fowler
> > One CGI question - since all of my CGIs are spitting out HTML is their > source code safe? wget and linking to the source deliver the output > HTML. Are there any other methods of trying to steal the source CGI I > need to protect against? > > Thank you. Not sure I fully understand the questi

Re: Pull Last 3 Months

2007-10-17 Thread Shane Geiger
A simpler way, imho: import datetime m = { 1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun',7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec' } month = datetime.date.today().month if month == 1: ans = [m[11], m[12], m[1]] elif month == 2: ans = [m[11], m[12], m[1]] else: ans = [m[month

Re: Last iteration?

2007-10-17 Thread Raymond Hettinger
[Paul Hankin] > def lastdetector(iterable): > t, u = tee(iterable) > return izip(chain(imap(lambda x: False, islice(u, 1, None)), > [True]), t) Sweet! Nice, clean piece of iterator algebra. We need a C-speed verion of the lambda function, something like a K combinator that consum

Python Labs Move

2007-10-17 Thread Bill Garey
What is PYTHON 2.2.1 and what does it do? I see the Program on my list of programs but don't know how to use it , or what it is! [EMAIL PROTECTED]-- http://mail.python.org/mailman/listinfo/python-list

if instance exists problem ..

2007-10-17 Thread stef mientki
hello, I've written a convenience wrapper around ConfigObj (which is a imporved ConfigParser). Now if I use an instance of the base class, I can easily test is the instance exists by " if ini:", like in this example ini = None if ini: print 'ok',type(ini) else: prin

Re: Noob questions about Python

2007-10-17 Thread Paul Hankin
On Oct 17, 10:58 pm, Ixiaus <[EMAIL PROTECTED]> wrote: > Thank you for the quick responses. > > I did not know that about integer literals beginning with a '0', so > thank you for the explanation. I never really use PHP except for > handling basic forms and silly web stuff, this is why I picked up

Re: negative base raised to fractional exponent

2007-10-17 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > Thank you for this. Now I need to somehow express this as a real > number. For example, I can transform the real and imaginary parts > into a polar coordinate giving me the value I want: > > z = sqrt( real_part**2 + imaj_part**2 ) > > but this is an absolute terms.

Re: Problem of Readability of Python

2007-10-17 Thread kiilerix
On Oct 17, 9:11 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On 10/17/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >>> o = object() > > >>> o.foo = 7 > > What makes you think it can't be instantiated directly? You just did > it. It's not, however, suitable for use as an arbitrary thing t

Re: Noob questions about Python

2007-10-17 Thread Ixiaus
Thank you for the quick responses. I did not know that about integer literals beginning with a '0', so thank you for the explanation. I never really use PHP except for handling basic forms and silly web stuff, this is why I picked up Python because I want to teach myself a more powerful and broad

* Pedophile Al-Qaida Brown Muslim Kills 6 Devout Christian Policement for Enjoying a Party - Atom Bomb his country to stone age *

2007-10-17 Thread thermate
http://www.cnn.com/2007/US/10/08/wisconsin.shooting/?iref=mpstoryview updated 8:39 p.m. EDT, Mon October 8, 2007 Deputy fired 30 shots from rifle in killing 6, officials say CRANDON, Wisconsin (CNN) -- An off-duty sheriff's deputy used a police- style AR-15 rifle to kill six people at an early m

Re: Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Paul Hankin
On Oct 17, 10:03 pm, Debajit Adhikary <[EMAIL PROTECTED]> wrote: > How does "a.extend(b)" compare with "a += b" when it comes to > performance? Does a + b create a completely new list that it assigns > back to a? If so, a.extend(b) would seem to be faster. How could I > verify things like these? U

Re: Noob questions about Python

2007-10-17 Thread Bjoern Schliessmann
Ixiaus wrote: > val = 'string' > li = list(val) > print li.reverse() > > returns nothing, but, Yes -- li.reverse() returns None. "print None" prints nothing. > val = 'string' > li = list(val) > li.reverse() > print li > > returns what I want. I'm afraid not. li.reverse() still returns None,

Re: Pull Last 3 Months

2007-10-17 Thread Paul Hankin
On Oct 17, 9:59 pm, Harlin Seritt <[EMAIL PROTECTED]> wrote: > Is there a module that can pull str values for say the last 3 months? > Something like: > > print lastMonths(3) > > ['Sep', 'Aug', 'Jul'] You should take a look at the 'datetime' module. You can get the current month: datetime.datetim

Re: Pull Last 3 Months

2007-10-17 Thread Tim Chase
> Is there a module that can pull str values for say the last 3 months? > Something like: > > print lastMonths(3) > > ['Sep', 'Aug', 'Jul'] I don't think there's anything inbuilt. It's slightly frustrating that timedelta doesn't accept a "months" parameter when it would be rather helpful (but

Re: Bidirectional communication over unix socket (named pipe)

2007-10-17 Thread Raúl Gómez C.
BTW: This is the original post: Hi, I feel like I should apologize in advance because I must be missing something fairly basic and fundamental here. I don't have a book on Python network programming (yet) and I haven't been able to find an answer on the net so far. I am trying to create a pair o

Bidirectional communication over unix socket (named pipe)

2007-10-17 Thread Raúl Gómez C.
Hi Jeffrey, I've been reading the Python mailing list and I've found a post of you about Unix socket with Python, you've found the answer to you're problem by your self, but I wonder if you still has the working code and if you would share it? Thanks!... Raul On *Wed Mar 8 18:11:11 CET 2006, *

Re: CGI and external JavaScript nightmare

2007-10-17 Thread IamIan
Thank you for the replies. After a lot of research I tracked down the issue. I was using the CGI to build all of the pages for the site, then filling in content with .innerHTML= as users clicked on tabs. Since I wanted to place the Google Ads in different parts of each page, the Google Ads JavaScri

Re: Need help in updating a global variable by a thread

2007-10-17 Thread Paul Hankin
On Oct 17, 7:48 pm, [EMAIL PROTECTED] wrote: > Hello Folks, > > My first posting here and I am a stuck in figuring out the exact way > to update a global variable from within a function that doesnt return > any value (because the function is a target of the thread and I dont > know how exactly retu

Re: Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Debajit Adhikary
On Oct 17, 4:41 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Wed, 2007-10-17 at 20:27 +, Debajit Adhikary wrote: > > I have two lists: > > > a = [1, 2, 3] > > b = [4, 5, 6] > > > What I'd like to do is append all of the elements of b at the end of > > a, so that a looks like: > > > a = [1,

Pull Last 3 Months

2007-10-17 Thread Harlin Seritt
Is there a module that can pull str values for say the last 3 months? Something like: print lastMonths(3) ['Sep', 'Aug', 'Jul'] Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help in updating a global variable by a thread

2007-10-17 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hello Folks, > > My first posting here and I am a stuck in figuring out the exact way > to update a global variable from within a function that doesnt return > any value (because the function is a target of the thread and I dont > know how exactly return would work in

Re: sqlite and TemporaryFile under Windows

2007-10-17 Thread Matthieu Brucher
> > Besides the fact that database management systems need lots of > random file accesses? That doesn't imply not supporting file-object. BTW, how is it possible to close the access to the database ? I deleted the object but Winows tells me that someone is still holding the file. Matthi

Pull Last 3 Months

2007-10-17 Thread Harlin Seritt
Is there a module that can pull str values for say the last 3 months? Something like: print lastMonths(3) ['Sep', 'Aug', 'Jul'] Thanks -- http://mail.python.org/mailman/listinfo/python-list

Async XMLRPC and job processing

2007-10-17 Thread Sean Davis
I would like to set up a server that takes XMLRPC requests and processes them asynchronously. The XMLRPC server part is trivial in python. The job processing part is the part that I am having trouble with. I have been looking at how to use threadpool, but I can't see how to get that working. I

Re: Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Paul Hankin
On Oct 17, 9:27 pm, Debajit Adhikary <[EMAIL PROTECTED]> wrote: > I have two lists: > > a = [1, 2, 3] > b = [4, 5, 6] > > What I'd like to do is append all of the elements of b at the end of > a, so that a looks like: > > a = [1, 2, 3, 4, 5, 6] > > I can do this using > > map(a.append, b) > > How d

Re: pymssql - insert NULL to int

2007-10-17 Thread rc
On Oct 17, 11:07 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > rc wrote: > > How to insert NULL values in to int field using params. > > > I'm trying to use pymssql.execute, passing the operation and list of > > params. One of the values in the params is a NULL value going to int > > field.

Re: Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Carsten Haese
On Wed, 2007-10-17 at 20:27 +, Debajit Adhikary wrote: > I have two lists: > > a = [1, 2, 3] > b = [4, 5, 6] > > What I'd like to do is append all of the elements of b at the end of > a, so that a looks like: > > a = [1, 2, 3, 4, 5, 6] > > I can do this using > > map(a.append, b) > > How

Re: pyparsing batch file

2007-10-17 Thread Paul McGuire
On Oct 17, 4:47 pm, Fabian Braennstroem <[EMAIL PROTECTED]> wrote: > Unfortunately, it does not parse the whole file names with > the underscore and I do not know yet, how I can access the > line with 'define/boundary-conditions'. Every 'argument' of > that command should become a separate python

Re: negative base raised to fractional exponent

2007-10-17 Thread John J. Lee
[EMAIL PROTECTED] writes: [...] > Thank you for this. Now I need to somehow express this as a real > number. For example, I can transform the real and imaginary parts into > a polar coordinate giving me the value I want: > > z = sqrt( real_part**2 + imaj_part**2 ) > > but this is an absolute terms.

Re: Noob questions about Python

2007-10-17 Thread Neil Cerutti
On 2007-10-17, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Ixiaus a écrit : >> val = 00110 >> >> as the integer 72 instead of returning 00110, why does Python >> do that? > > Literal integers starting with '0' (zero) are treated as octal. > It's a pretty common convention (like 0x for hexa).

Re: Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Marc 'BlackJack' Rintsch
On Wed, 17 Oct 2007 20:27:14 +, Debajit Adhikary wrote: > I have two lists: > > a = [1, 2, 3] > b = [4, 5, 6] > > What I'd like to do is append all of the elements of b at the end of > a, so that a looks like: > > a = [1, 2, 3, 4, 5, 6] > > I can do this using > > map(a.append, b) This i

Re: Noob questions about Python

2007-10-17 Thread Paul Hankin
On Oct 17, 8:37 pm, Ixiaus <[EMAIL PROTECTED]> wrote: > I have a few questions regarding Python behavior... > as the integer 72 instead of returning 00110, why does Python do that? > (and how can I get around it?) You can do this: def bin(x): return int(x, 2) val = bin('00110') -- Paul Hank

Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Debajit Adhikary
I have two lists: a = [1, 2, 3] b = [4, 5, 6] What I'd like to do is append all of the elements of b at the end of a, so that a looks like: a = [1, 2, 3, 4, 5, 6] I can do this using map(a.append, b) How do I do this using a list comprehension? (In general, is using a list comprehension pref

Re: urlgrabber cookie handling?

2007-10-17 Thread John J. Lee
Devraj <[EMAIL PROTECTED]> writes: > Hi everyone, > > I have been battling to make my code work with a HTTPS proxy, current > my code uses urllib2 to to most things and works well, except that > urllib2 doesn't handle HTTPS proxies. > > Urlgrabber (http://linux.duke.edu/projects/urlgrabber/help/ >

Re: Noob questions about Python

2007-10-17 Thread Bruno Desthuilliers
Ixiaus a écrit : > I have recently (today) just started learning/playing with Python. So > far I am excited and impressed Welcome onboard then !-) > (coming from PHP background). > > I have a few questions regarding Python behavior... > > val = 'string' > li = list(val) > print li.reverse() >

Re: Noob questions about Python

2007-10-17 Thread Adam Atlas
On Oct 17, 3:37 pm, Ixiaus <[EMAIL PROTECTED]> wrote: > I have recently (today) just started learning/playing with Python. So > far I am excited and impressed (coming from PHP background). > > I have a few questions regarding Python behavior... > > val = 'string' > li = list(val) > print li.reverse

Re: Can you determine the sign of the polar form of a complex number?

2007-10-17 Thread Jason
On Oct 17, 7:51 am, [EMAIL PROTECTED] wrote: > Just to clarify what I'm after: > > If you plot (-3)^n where n is a set of negative real numbers between 0 > and -20 for example, then you get a discontinuos line due to the > problem mentioned above with fractional exponents. However, you can > comput

Re: Noob questions about Python

2007-10-17 Thread Furkan Kuru
li.reverse() does not return a list it just changes the list li. val = 00110 is evaluated in base 8 try without leading 0s On 10/17/07, Ixiaus <[EMAIL PROTECTED]> wrote: > > I have recently (today) just started learning/playing with Python. So > far I am excited and impressed (coming from PHP b

pyparsing batch file

2007-10-17 Thread Fabian Braennstroem
Hi, me again :-) I would like to parse a small batch file: file/read-case kepstop.cas file/read-data keps1500.dat solve/monitors/residual/plot no solve/monitors/residual/print yes /define/boundary-conditions in velocity-inlet 10 0.1 0.1 no 1 it 500 wd keps1500_500.dat yes exit Right now, I use

Re: Noob questions about Python

2007-10-17 Thread Grant Edwards
On 2007-10-17, Ixiaus <[EMAIL PROTECTED]> wrote: > val = 'string' > li = list(val) > print li.reverse() > > returns nothing, but, > > val = 'string' > li = list(val) > li.reverse() > print li > > returns what I want. Why does Python do that? Because it does. :) > Also I have been playing around

open remote terminal

2007-10-17 Thread Fabian Braennstroem
Hi, I would like to use python to start an terminal, e.g. xterm, and login on a remote machine using rsh or ssh. This could be done using 'xterm -e ssh machine', but after the login I would like to jump to a given directory. Does anyone have an idea how to do this with python? Regards! Fabian --

Re: Stopping a fucntion from printing its output on screen

2007-10-17 Thread MRAB
On Oct 17, 4:01 pm, Jeremy Sanders wrote: > sophie_newbie wrote: > > Hi, in my program i need to call a couple of functions that do some > > stuff but they always print their output on screen. But I don't want > > them to print anything on the screen. Is there any way I can disable > > it from doi

Noob questions about Python

2007-10-17 Thread Ixiaus
I have recently (today) just started learning/playing with Python. So far I am excited and impressed (coming from PHP background). I have a few questions regarding Python behavior... val = 'string' li = list(val) print li.reverse() returns nothing, but, val = 'string' li = list(val) li.reverse(

Noob questions about Python

2007-10-17 Thread Ixiaus
I have recently (today) just started learning/playing with Python. So far I am excited and impressed (coming from PHP background). I have a few questions regarding Python behavior... val = 'string' li = list(val) print li.reverse() returns nothing, but, val = 'string' li = list(val) li.reverse(

Re: linear programming in Python

2007-10-17 Thread Carl Banks
On Oct 17, 11:44 am, [EMAIL PROTECTED] wrote: > Hi all, > > I'm new to this group so I don't know if this question has been posted > before, but does anyone knows about linear/integer programming > routines in Python that are available on the web, more specifically of > the branch and bound method.

  1   2   3   >