Re: importing modules question

2007-10-18 Thread Amit Khemka
On 10/18/07, warhero <[EMAIL PROTECTED]> wrote: > 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 > > l

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

2007-10-18 Thread Gerard Flanagan
On Oct 18, 1:55 am, Debajit Adhikary <[EMAIL PROTECTED]> 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? > from iter

Re: A near realtime file system mirror application written in Python

2007-10-18 Thread Roc Zhou
mirrord/fs_mirror makes use of inotify, which is a functionality afforded by the recent Linux (from 2.6.12). It is a counterpart of FAM, since Linux FAM has stopped so long. On 10/17/07, Roc Zhou <[EMAIL PROTECTED]> wrote: > > Hello: > > Recently I started an open source project "cutils" on the >

Re: Last iteration?

2007-10-18 Thread Paul Hankin
On Oct 17, 11:45 pm, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > [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 nee

Re: Stopping a fucntion from printing its output on screen

2007-10-18 Thread Paul Hankin
On Oct 17, 3:57 pm, sophie_newbie <[EMAIL PROTECTED]> 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 doing this, like

[OT] PLEASE HELP US

2007-10-18 Thread Albert77
Hello, my name is Albert and I'm looking for help. Please visit my web page. www.willmarry.net Thanks Albert -- http://mail.python.org/mailman/listinfo/python-list

MOD_PYTHON + packages reloading

2007-10-18 Thread lukasz . f24
Hello, I came across annoying problem during my fun with mod_python. I turned out that mod_python load package only onca and don't care about any changes to it. Obviously it makes sense on production server but during development is more then annoying. I find a way to reload my module: m = ap

Re: ANN: magnitude 0.9.1

2007-10-18 Thread Joan M. Garcia
George Sakkis <[EMAIL PROTECTED]> writes: > On Oct 16, 7:35 am, Laurent Pointal <[EMAIL PROTECTED]> > >> How does it compare to the scalar module ? >> (seehttp://russp.us/scalar.htm) > > or the Unum module (http://home.scarlet.be/be052320/Unum.html) ? Both scalar and unum treat units as variables.

Re: ANN: magnitude 0.9.1

2007-10-18 Thread juan
> A further issue, that requires a change of interface: Please comply > with PEP 8 http://www.python.org/dev/peps/pep-0008/> for your > module interface. In particular, please name classes with TitleCase, > and functions, methods, and instance names with > lower_case. Done, almost. I should have

ANN: magnitude 0.9.2

2007-10-18 Thread Joan M. Garcia
Following the feedback on the first release of magnitude it has changed enough to deserve a second release, which modifies the API, solves a couple of bugs, and brings it in line with python's style guide. Main changes: * imul, idiv had wrong output unit, so that after a /= b printing showed wr

Re: Strange behaviour with reversed()

2007-10-18 Thread Steven D'Aprano
On Thu, 18 Oct 2007 02:49:12 -0300, Gabriel Genellina wrote: > A reversed object is rather simple: it stores the original sequence (a > reference, as usual, not a copy!) and the next index to use, starting at > len-1. Each time the next() method is called, the index is decremented > until it goes

Re: Strange behaviour with reversed()

2007-10-18 Thread Steven D'Aprano
On Thu, 18 Oct 2007 15:24:27 +1000, Ben Finney wrote: > 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

Re: MOD_PYTHON + packages reloading

2007-10-18 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > I came across annoying problem during my fun with mod_python. I turned > out that mod_python load package only onca and don't care about any > changes to it. Obviously it makes sense on production server but > during development is more then annoying. Have you read the

Re: if instance exists problem ..

2007-10-18 Thread Diez B. Roggisch
Ben Finney wrote: > "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. I've misread th

Re: Strange behaviour with reversed()

2007-10-18 Thread Duncan Booth
Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> Note that the starting index is determined at creation time, not when >> the iteration begins. So, if you create a reversed object over a list >> containing 3 elements, the first returned element will be seq[2], then >> seq[1], then seq[0]. It doesn't

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

2007-10-18 Thread Hrvoje Niksic
Paul Hankin <[EMAIL PROTECTED]> writes: > 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 fast

Re: Order by value in dictionary

2007-10-18 Thread Duncan Booth
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > Without throwing away 500 items: > > def sortt(d): > sorted_items = sorted(d.iteritems(), > key=operator.itemgetter(1), > reverse=True) > return map(operator.itemgetter(0), sorted_ite

Re: MOD_PYTHON + packages reloading

2007-10-18 Thread lukasz . f24
On 18 Oct, 09:55, Duncan Booth <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I came across annoying problem during my fun with mod_python. I turned > > out that mod_python load package only onca and don't care about any > > changes to it. Obviously it makes sense on production server bu

Re: Problem of Readability of Python

2007-10-18 Thread Marc 'BlackJack' Rintsch
On Wed, 17 Oct 2007 15:01:09 -0700, kiilerix wrote: > 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

Re: MOD_PYTHON + packages reloading

2007-10-18 Thread Graham Dumpleton
On Oct 18, 6:55 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I came across annoying problem during my fun with mod_python. I turned > > out that mod_python load package only onca and don't care about any > > changes to it. Obviously it makes sense on production server

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

2007-10-18 Thread Amit Khemka
On 10/18/07, Carsten Haese <[EMAIL PROTECTED]> wrote: > 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 > > >

Re: Script to Download Ubuntu Gutsy ASAP

2007-10-18 Thread Eduardo O. Padoan
On 10/18/07, danfolkes <[EMAIL PROTECTED]> wrote: > 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 wo

Re: ANN: magnitude 0.9.2

2007-10-18 Thread Thomas Heller
Joan M. Garcia schrieb: > Following the feedback on the first release of magnitude it > has changed enough to deserve a second release, which > modifies the API, solves a couple of bugs, and brings it in > line with python's style guide. Main changes: > > * imul, idiv had wrong output unit, so th

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

2007-10-18 Thread Paul Hankin
On Oct 18, 12:11 pm, "Amit Khemka" <[EMAIL PROTECTED]> wrote: > On 10/18/07, Carsten Haese <[EMAIL PROTECTED]> wrote: > > Rather than spelling out the final result, I'll give you hints: Look at > > itertools.cycle and itertools.izip. > > Why not just use enumerate ? > > clvalues = ["Even", "Odd"] >

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

2007-10-18 Thread Paul Hankin
On Oct 18, 10:21 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Paul Hankin <[EMAIL PROTECTED]> writes: > > 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 t

Re: Order by value in dictionary

2007-10-18 Thread Amit Khemka
On 10/17/07, Abandoned <[EMAIL PROTECTED]> wrote: > Very very thanks everbody.. > > These are some method.. > Now the fastest method is second.. > > 1 === > def sortt(d): > items=d.items() > backitems=[ [v[1],v[0]] for v in items] > backitems.sort() > #boyut=len(backitems) >

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

2007-10-18 Thread Bruno Desthuilliers
Debajit Adhikary a écrit : > 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) And what about a.extend(b) ? > How do I

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

2007-10-18 Thread Brian Blais
On Oct 18, 2007, at Oct 18:7:47 AM, Paul Hankin wrote: On Oct 18, 12:11 pm, "Amit Khemka" <[EMAIL PROTECTED]> wrote: Why not just use enumerate ? clvalues = ["Even", "Odd"] for i, (id, name) in enumerate(result): stringBuffer.write(''' %d %s ''' %

Re: Inheriting automatic attributes initializer considered harmful?

2007-10-18 Thread Andrew Durdin
On 10/17/07, Alex Martelli <[EMAIL PROTECTED]> wrote: > > fake_str is not called, because special-method lookup occurs on the > TYPE, *NOT* on the instance. So it does; I'd forgotten that. I need to remember to actually check that the code does what I think it does before posting it on c.l.p :-|

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

2007-10-18 Thread Grant Edwards
On 2007-10-18, Gerard Flanagan <[EMAIL PROTECTED]> wrote: > On Oct 18, 1:55 am, Debajit Adhikary <[EMAIL PROTECTED]> 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

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

2007-10-18 Thread Hrvoje Niksic
Paul Hankin <[EMAIL PROTECTED]> writes: > Not to me: I can never remember which of a.append and a.extend is > which. Interesting, with me it's the other way around. Maybe it's because I used Python before extend was available. > Falling back to a = a + b is exactly what you want. Not if you wa

Re: Noob questions about Python

2007-10-18 Thread Stargaming
On Wed, 17 Oct 2007 22:05:36 +0200, Bruno Desthuilliers wrote: [snip] > > Note that there's also the reverse() function that returns a reverse > iterator over any sequence, so you could also do: > > li = list('allo') > print ''.join(reverse(li)) > Note this certainly should've been `reversed()`

Re: ANN: magnitude 0.9.2

2007-10-18 Thread juan
Thomas Heller <[EMAIL PROTECTED]> writes: > - "physical", not "phisical" ;-) I see a worrisome pattern starting to emerge :-). Thanks. > - you raise string exceptions in various places; these are > deprecated and should not be used. Also it is very > difficult to catch them. Yes, I believe it

Re: Noob questions about Python

2007-10-18 Thread Bruno Desthuilliers
Stargaming a écrit : > On Wed, 17 Oct 2007 22:05:36 +0200, Bruno Desthuilliers wrote: > [snip] >> Note that there's also the reverse() function that returns a reverse >> iterator over any sequence, so you could also do: >> >> li = list('allo') >> print ''.join(reverse(li)) >> > > Note this certain

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

2007-10-18 Thread dedalusenator
First off, apologies for posting code that had issues. My bad and promise next time to do due diligence. >learn about semaphores. Definitely will. >While this may not be an issue in this snippet Even when more than one user concurrently launches this python program? Let me read up on this like

Re: Capturing OutputDebugString information in python

2007-10-18 Thread Tim Golden
danbrotherston wrote: > > > Wow, more of a response than I expected, thanks very much for the > research. While not related to the mutex, the problem did appear to > be permission related. For the record, on windows XP > > import sys > import mmap > import win32event > > buffer_ready = win32e

Re: Capturing OutputDebugString information in python

2007-10-18 Thread danbrotherston
Wow, more of a response than I expected, thanks very much for the research. While not related to the mutex, the problem did appear to be permission related. For the record, on windows XP import sys import mmap import win32event buffer_ready = win32event.CreateEvent (None, 0, 0, "DBWIN_BUFFER_

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

2007-10-18 Thread Alex Martelli
Grant Edwards <[EMAIL PROTECTED]> wrote: ... > I like the solution somebody sent me via PM: > > def toggle(): > while 1: > yield "Even" > yield "Odd" I think the itertools-based solution is more elegant: toggle = itertools.cycle(('Even', 'Odd')) and use toggle rather than

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

2007-10-18 Thread Alex Martelli
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? That's what the

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

2007-10-18 Thread Iain King
On Oct 18, 2:29 am, Grant Edwards <[EMAIL PROTECTED]> wrote: > 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)

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

2007-10-18 Thread J. Clifford Dyer
On Thu, Oct 18, 2007 at 11:57:10AM -, Paul Hankin wrote regarding Re: Appending a list's elements to another list using a list comprehension: > > Not to me: I can never remember which of a.append and a.extend is > which. Falling back to a = a + b is exactly what you want. For > instance: > >

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

2007-10-18 Thread cokofreedom
On Oct 18, 3:48 pm, Iain King <[EMAIL PROTECTED]> wrote: > On Oct 18, 2:29 am, Grant Edwards <[EMAIL PROTECTED]> wrote: > > > > > On 2007-10-17, Debajit Adhikary <[EMAIL PROTECTED]> wrote: > > > > # Start of Code > > > > def evenOdd(): > > > values = ["Even", "Odd"] > > > state = 0 > > >

Re: Version specific or not?

2007-10-18 Thread Steve Holden
Scott David Daniels wrote: > Steven W. Orr wrote: >> We have an app and I'm trying to decide where the app ... . >> /usr/lib/python2.3/site-packages >> or >> /usr/lib/site-python >> >> The latter would solve a lot of problems for me. > Fewer than you suspect > >> If there are multiple versions of

Convert string to command..

2007-10-18 Thread Abandoned
I want to convert a string to command.. For example i have a string: a="['1']" I want to do this list.. How can i do ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert string to command..

2007-10-18 Thread Adam Atlas
On Oct 18, 10:23 am, Abandoned <[EMAIL PROTECTED]> wrote: > I want to convert a string to command.. > For example i have a string: > a="['1']" > I want to do this list.. > How can i do ? Use the builtin function "eval". -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert string to command..

2007-10-18 Thread Diez B. Roggisch
Abandoned wrote: > I want to convert a string to command.. > For example i have a string: > a="['1']" > I want to do this list.. > How can i do ? The correct wording here would be expression. To evaluate expressions, there is the function eval: a = eval("['1']") But beware: if the expression co

Re: Pull Last 3 Months

2007-10-18 Thread Hyuga
On Oct 18, 12:25 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > I prefer the calendar module in that case: > > py> import locale > py> locale.setlocale(locale.LC_ALL, '') > 'Spanish_Argentina.1252' > py> > py> import calendar > py> calendar.month_abbr[12] > 'Dic' > py> def prev_months(since,

Re: Convert string to command..

2007-10-18 Thread Abandoned
Thanks you all answer.. But "eval" is very slow at very big dictionary {2:3,4:5,6:19} (100.000 elements) Is there any easy alternative ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert string to command..

2007-10-18 Thread Diez B. Roggisch
Abandoned wrote: > Thanks you all answer.. > But "eval" is very slow at very big dictionary {2:3,4:5,6:19} > (100.000 elements) > Is there any easy alternative ? How big? How slow? For me, a 1-element list takes 0.04 seconds to be parsed. Which I find fast. Diez -- http://mail.python.o

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 6:14 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Abandoned wrote: > > Thanks you all answer.. > > But "eval" is very slow at very big dictionary {2:3,4:5,6:19} > > (100.000 elements) > > Is there any easy alternative ? > > How big? How slow? For me, a 1-element list takes

Re: pymssql - insert NULL to int

2007-10-18 Thread Diez B. Roggisch
rc wrote: > 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

Re: open remote terminal

2007-10-18 Thread Steve Holden
Fabian Braennstroem wrote: > 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

Re: CGI and external JavaScript nightmare

2007-10-18 Thread Steve Holden
allen.fowler wrote: >> 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

Re: Convert string to command..

2007-10-18 Thread Hrvoje Niksic
Abandoned <[EMAIL PROTECTED]> writes: > 173.000 dict elements and it tooks 2.2 seconds this very big time > for my project If you're generating the string from Python, use cPickle instead. Much faster: >>> import time >>> d = dict((i, i+1) for i in xrange(17)) >>> len(d) 17 >>> s=repr(d)

Re: Convert string to command..

2007-10-18 Thread Diez B. Roggisch
Abandoned wrote: > On Oct 18, 6:14 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> Abandoned wrote: >> > Thanks you all answer.. >> > But "eval" is very slow at very big dictionary {2:3,4:5,6:19} >> > (100.000 elements) >> > Is there any easy alternative ? >> >> How big? How slow? For me,

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 6:26 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Abandoned <[EMAIL PROTECTED]> writes: > > 173.000 dict elements and it tooks 2.2 seconds this very big time > > for my project > > If you're generating the string from Python, use cPickle instead. > Much faster: > > >>> import time > >>

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 6:35 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Abandoned wrote: > > On Oct 18, 6:14 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >> Abandoned wrote: > >> > Thanks you all answer.. > >> > But "eval" is very slow at very big dictionary {2:3,4:5,6:19} > >> > (100.000 el

Re: Convert string to command..

2007-10-18 Thread Marc 'BlackJack' Rintsch
On Thu, 18 Oct 2007 08:41:30 -0700, Abandoned wrote: > import cPickle as pickle > a="{2:3,4:6,2:7}" > s=pickle.dumps(a, -1) > g=pickle.loads(s); > print g > '{2:3,4:6,2:7}' > > Thank you very much for your answer but result is a string ?? In Python terms yes, strings in Python can contain any by

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 6:51 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Thu, 18 Oct 2007 08:41:30 -0700, Abandoned wrote: > > import cPickle as pickle > > a="{2:3,4:6,2:7}" > > s=pickle.dumps(a, -1) > > g=pickle.loads(s); > > print g > > '{2:3,4:6,2:7}' > > > Thank you very much for your answe

version 1.4 of scalar class released

2007-10-18 Thread [EMAIL PROTECTED]
Version 1.4 of my scalar class is available at http://RussP.us/scalar.htm No major changes. I have corrected the "repr" function to make it more useful, and I have added a "unit_type" function that returns the type of a unit (e.g., time, length, force). The unit_type function is intended mainly f

Re: Convert string to command..

2007-10-18 Thread Diez B. Roggisch
Abandoned wrote: > On Oct 18, 6:35 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> Abandoned wrote: >> > On Oct 18, 6:14 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> >> Abandoned wrote: >> >> > Thanks you all answer.. >> >> > But "eval" is very slow at very big dictionary {2:3,4:5,6:1

Pyinotify : which user ?

2007-10-18 Thread Sébastien Weber
Hello, I'm actually writing an application with pyinotify which watchs a directory. Pyinotify lets me know the events (access, modify, suppression, etc.) on and in the directory, but not the users who are responsable of them. Does someone know a library which could give me that information (who'

strptime and microseconds

2007-10-18 Thread mathieu
Hi there, I am trying to use strptime to parse my microseconds but I was not able the documentation for it. The only list I found was: http://docs.python.org/lib/module-time.html So I can get seconds with %S, but nowhere is there a microsecond symbol... Thanks for pointer to doc, -Mathieu

Re: Convert string to command..

2007-10-18 Thread Hrvoje Niksic
Abandoned <[EMAIL PROTECTED]> writes: > import cPickle as pickle > a="{2:3,4:6,2:7}" > s=pickle.dumps(a, -1) > g=pickle.loads(s); > print g > '{2:3,4:6,2:7}' > > Thank you very much for your answer but result is a string ?? Because you gave it a string. If you give it a dict, you'll get a dict:

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 6:57 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Abandoned wrote: > > On Oct 18, 6:35 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >> Abandoned wrote: > >> > On Oct 18, 6:14 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >> >> Abandoned wrote: > >> >> > Thanks you all

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 7:02 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Abandoned <[EMAIL PROTECTED]> writes: > > import cPickle as pickle > > a="{2:3,4:6,2:7}" > > s=pickle.dumps(a, -1) > > g=pickle.loads(s); > > print g > > '{2:3,4:6,2:7}' > > > Thank you very much for your answer but result is a string ?

Re: Convert string to command..

2007-10-18 Thread Hrvoje Niksic
Abandoned <[EMAIL PROTECTED]> writes: > I select where id=56 and 100.000 rows are selecting but this took 2 > second. (very big for my project) > I try cache to speed up this select operation.. > And create a cache table: > id-1 | all > 56{68:66, 98:32455, 62:655} If you use Python to create

Re: Convert string to command..

2007-10-18 Thread Matimus
On Oct 18, 9:09 am, Abandoned <[EMAIL PROTECTED]> wrote: > On Oct 18, 6:57 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > > > > Abandoned wrote: > > > On Oct 18, 6:35 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > >> Abandoned wrote: > > >> > On Oct 18, 6:14 pm, "Diez B. Roggisch" <[E

Re: strptime and microseconds

2007-10-18 Thread mathieu
On Oct 18, 6:36 pm, mathieu <[EMAIL PROTECTED]> wrote: > On Oct 18, 6:00 pm, mathieu <[EMAIL PROTECTED]> wrote: > > > > > Hi there, > > > I am trying to use strptime to parse my microseconds but I was not > > able the documentation for it. The only list I found was: > > > http://docs.python.org/

Re: strptime and microseconds

2007-10-18 Thread mathieu
On Oct 18, 6:00 pm, mathieu <[EMAIL PROTECTED]> wrote: > Hi there, > > I am trying to use strptime to parse my microseconds but I was not > able the documentation for it. The only list I found was: > > http://docs.python.org/lib/module-time.html > > So I can get seconds with %S, but nowhere is

Re: some questions about Python and tkinter

2007-10-18 Thread fabdeb
On Oct 16, 9:17 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Tue, 16 Oct 2007 11:52:22 -0700, fabdeb wrote: > > the first: what is the differences between a function and a classe? > > A class bundles data and functions into one object. > > > In which case i should use a function ? >

Re: Convert string to command..

2007-10-18 Thread Hrvoje Niksic
Abandoned <[EMAIL PROTECTED]> writes: > Sorry i can't understand :( > Yes my database already has data in the "{..}" format and i select > this and i want to use it for dictionary.. But, do you use Python to create that data? If so, simply convert it to pickle binary format instead of "{...}".

Fwd: Pyinotify : which user ?

2007-10-18 Thread Roc Zhou
-- Forwarded message -- From: Roc Zhou <[EMAIL PROTECTED]> Date: Oct 19, 2007 12:48 AM Subject: Re: Pyinotify : which user ? To: Sébastien Weber <[EMAIL PROTECTED]> The command lsof or fuser can report who is using the file, maybe you can have a look at their source code, but they

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 7:40 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Abandoned <[EMAIL PROTECTED]> writes: > > Sorry i can't understand :( > > Yes my database already has data in the "{..}" format and i select > > this and i want to use it for dictionary.. > > But, do you use Python to create that data?

Re: Convert string to command..

2007-10-18 Thread Sebastian Bassi
On 10/18/07, Adam Atlas <[EMAIL PROTECTED]> wrote: > > Use the builtin function "eval". What is the difference with os.system()? -- Sebastián Bassi (セバスティアン). Diplomado en Ciencia y Tecnología. Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6 GPG Fingerprint: 9470 0980 620D

Re: CGI and external JavaScript nightmare

2007-10-18 Thread Paul Boddie
On 18 Okt, 17:24, Steve Holden <[EMAIL PROTECTED]> wrote: > allen.fowler wrote: [Quoting IamIan...] > >> 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

Re: Convert string to command..

2007-10-18 Thread Richard Brodie
"Matimus" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I think several people have given you the correct answer, but for some > reason you aren't getting it. Instead of saving the string > representation of a dictionary to the database... Mind you, if this were Jeopardy, "Store

Re: python logging module and custom handler specified in config file

2007-10-18 Thread Vinay Sajip
On 15 Oct, 15:15, Frank Aune <[EMAIL PROTECTED]> wrote: > What I'm wondering, is if its possible to specify the database handler in a > config file like: > > [handler_database] > class=DBHandler > level=DEBUG > formatter=database > args=('localhost', uid='root') > > I've seen the log_test14.py exam

Re: Convert string to command..

2007-10-18 Thread Bruno Desthuilliers
Abandoned a écrit : > On Oct 18, 6:51 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Thu, 18 Oct 2007 08:41:30 -0700, Abandoned wrote: >>> import cPickle as pickle >>> a="{2:3,4:6,2:7}" >>> s=pickle.dumps(a, -1) >>> g=pickle.loads(s); >>> print g >>> '{2:3,4:6,2:7}' >>> Thank you ver

Re: Convert string to command..

2007-10-18 Thread Bruno Desthuilliers
Abandoned a écrit : (snip) > import cPickle as pickle > a="{2:3,4:6,2:7}" > s=pickle.dumps(a, -1) > g=pickle.loads(s); > print g > '{2:3,4:6,2:7}' > > Thank you very much for your answer but result is a string ?? > Of course it's a string. That's what you pickled. What did you hope ? If you want

Re: Convert string to command..

2007-10-18 Thread Bruno Desthuilliers
Richard Brodie a écrit : > "Matimus" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> I think several people have given you the correct answer, but for some >> reason you aren't getting it. Instead of saving the string >> representation of a dictionary to the database... > > Mi

Re: Convert string to command..

2007-10-18 Thread Bruno Desthuilliers
Abandoned a écrit : (snip) > I'm very confused :( > I try to explain main problem... > I have a table like this: > id-1 | id-2 | value > 23 24 34 > 56 68 66 > 56 98 32455 > 55 62 655 > 56 28 123 > ( 3 millions elements) > > I select where id=5

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

2007-10-18 Thread Luis Zarrabeitia
On Thursday 18 October 2007 09:09, Grant Edwards wrote: > I like the solution somebody sent me via PM: > > def toggle(): > while 1: > yield "Even" > yield "Odd" > That was me. Sorry, list, I meant to send it to everyone but I my webmail didn't respect the list* headers :(. Th

Re: Noob questions about Python

2007-10-18 Thread Arnaud Delobelle
On Oct 18, 7:06 am, Ixiaus <[EMAIL PROTECTED]> wrote: [...] > I know '<<' is shifting x over by n bits; but could you point me to > some literature that would explain why it is the same as "x*2**n"? I haven't got literature but I've got a (hopefully straightforward) explanation: In binary 2 is 10

Running another python interpreter

2007-10-18 Thread Simon Pickles
Hello, I have several servers which link to each other (and of course, to clients). At present, I am starting them in turn manually. Is there a way with python to say, "open gateway.py in a new interpreter window"? I looked at execv, etc, but they seem to replace the current process. Ah, maybe

Re: Convert string to command..

2007-10-18 Thread Hrvoje Niksic
Abandoned <[EMAIL PROTECTED]> writes: > > When you load it, convert the string to dict with cPickle.loads > > instead of with eval. > > Yes i understand and this very very good ;) Good! :-) > psycopg2.ProgrammingError: invalid byte sequence for encoding "UTF8": > 0x80 > HINT: This error can a

Re: Convert string to command..

2007-10-18 Thread Carsten Haese
On Thu, 2007-10-18 at 19:53 +0200, Hrvoje Niksic wrote: > Don't > forget to also use a bind variable, something like: > > cursor.execute("INSERT INTO cache2 VALUES (?)", a) I second the advice, but that code won't work. The bind parameters must be a sequence, and psycopg2 (unfortunately) uses %s

Re: Running another python interpreter

2007-10-18 Thread Simon Pickles
Well, I tried: os.spawnv(os.P_NOWAIT, "gateway.py", ()) and got: OSError: [Errno 8] Exec format Simon Pickles wrote: > Hello, > > I have several servers which link to each other (and of course, to clients). > > At present, I am starting them in turn manually. Is there a way with >

Problem with format string / MySQL cursor

2007-10-18 Thread Florian Lindner
Hello, I have a string: INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`, `gid`, `password`) VALUES (%s, %s, %s, %s, %i, %i, %s) that is passed to a MySQL cursor from MySQLdb: ret = cursor.execute(sql, paras) paras is: ('flindner', '[EMAIL PROTECTED]', '/home/flindner/', '/home

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

2007-10-18 Thread Debajit Adhikary
On Oct 18, 9:47 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > 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

Re: Strange behaviour with reversed()

2007-10-18 Thread Andreas Kraemer
On Oct 18, 2:25 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: > >> Note that the starting index is determined at creation time, not when > >> the iteration begins. So, if you create a reversed object over a list > >> containing 3 elements, the first return

1 year free

2007-10-18 Thread nayloon
www.nayloon.com business2business website.Full dynamic and 2 language 10 pages.You post your products you can find customer from all over world.Try it.You will see the different. -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedded Boost.Python Enum

2007-10-18 Thread Roman Yakovenko
On 10/18/07, Cory <[EMAIL PROTECTED]> wrote: > > 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("getTy

image resize question

2007-10-18 Thread Tim Arnold
Hi, I'm using the Image module to resize PNG images from 300 to 100dpi for use in HTML pages, but I'm losing some vertical and horizontal lines in the images (usually images of x-y plots). Here's what I do: import Image def imgResize(self,filename): img = Image.open(filename) dpi

Re: Strange behaviour with reversed()

2007-10-18 Thread Terry Reedy
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] |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

problem with Python class creating

2007-10-18 Thread dmitrey
Hi all, I have the code like this one: from myMisc import ooIter class MyClass: def __init__(self): pass iterfcn = lambda *args: ooIter(self) # i.e pass the class instance to other func named ooIter field2 = val2 field3 = val3 # etc So it yields "global name 'self' is not defined"

Re: Problem with format string / MySQL cursor

2007-10-18 Thread timaranz
On Oct 19, 7:32 am, Florian Lindner <[EMAIL PROTECTED]> wrote: > Hello, > I have a string: > > INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`, > `gid`, `password`) VALUES (%s, %s, %s, %s, %i, %i, %s) > > that is passed to a MySQL cursor from MySQLdb: > > ret = cursor.execute(sql,

Re: problem with Python class creating

2007-10-18 Thread Bruno Desthuilliers
dmitrey a écrit : > Hi all, > I have the code like this one: > > from myMisc import ooIter > class MyClass: Unless you have a need for compatibility with aged Python versions, you'd be better using new-style classes: class MyClass(object): > def __init__(self): pass This is the default be

Re: problem with Python class creating

2007-10-18 Thread timaranz
On Oct 19, 8:22 am, dmitrey <[EMAIL PROTECTED]> wrote: > Hi all, > I have the code like this one: > > from myMisc import ooIter > class MyClass: > def __init__(self): pass > iterfcn = lambda *args: ooIter(self) # i.e pass the class instance > to other func named ooIter > field2 = val2 >

Can you escape a % in string that will used for substitution

2007-10-18 Thread Gerard Brunick
Is there a way to do: s = "I like python %i%s of the time." print s % (99, "%") without having to pass in "%"? Thanks, Gerard -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >