Inspecting the Instance Vars in a class/object - How?

2008-08-27 Thread BrendanC
I'm trying to understand reflection/introspection in Python. How can I identify the the type of attribute (e.g. instance var) in a class? The following returns all the class attributes (methods and instance vars). However I'm interested in identifying the type of value for each case - (e.g. I'd li

unexpected from/import statement behaviour

2008-08-27 Thread nisp
Hi all ! I'm trying to capture stderr of an external module I use in my python program. I'm doing this by setting up a class in my module overwriting the stderr file object method write. The external module outputs to stderr this way: from sys import std err print >> stderr, "Some

Re: Using Python to shared memory resources between Linux and Windows

2008-08-27 Thread Diez B. Roggisch
Blubaugh, David A. schrieb: Diez, What you have said is extremely concerning. I am now using VMware. With Linux as the Master and windows as the guest operating system. I was wondering if you have ever had to develop a share memory resource between Linux and windows within a Vmware setup?

Re: unexpected from/import statement behaviour

2008-08-27 Thread Diez B. Roggisch
nisp schrieb: Hi all ! I'm trying to capture stderr of an external module I use in my python program. I'm doing this by setting up a class in my module overwriting the stderr file object method write. The external module outputs to stderr this way: from sys import std err print >

Re: unexpected from/import statement behaviour

2008-08-27 Thread alex23
nisp <[EMAIL PROTECTED]> wrote: > I've always been convinced of the equivalence of the two ways of using > the import statement but it's clear I'm wrong :-( Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "licens

newbie doubt about MVC,tkinter

2008-08-27 Thread gordon
hi i am trying to write a controller that creates a Tkinter gui,takes userevents from gui and calls another program to do some calculation and finally returns the results to gui to be displayed. I tried to separate these three like MVC pattern however ,being a newbie i have some doubts sample gui

Re: SQL package

2008-08-27 Thread Diez B. Roggisch
Juan schrieb: Hi I am trying to write a little a script that can be configurable. This script should access to a database, that can be of any type (MySQL, Postgres, SQLite, MS, etc).It has only to perform 2 or 3 simple plain SQL queries. Hi have tested SQLAlchemy, and it is great, but too much f

Re: unexpected from/import statement behaviour

2008-08-27 Thread Diez B. Roggisch
alex23 schrieb: nisp <[EMAIL PROTECTED]> wrote: I've always been convinced of the equivalence of the two ways of using the import statement but it's clear I'm wrong :-( Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "cre

Re: Python and database unittests

2008-08-27 Thread Marco Bizzarri
On Wed, Aug 27, 2008 at 4:55 AM, alex23 <[EMAIL PROTECTED]> wrote: > Daniel <[EMAIL PROTECTED]> wrote: >> Does anyone know about a module that acts as a database stub for >> python unittests? > > It's not database-specific, but the Mock module should help you here: > > http://python-mock.sourceforg

Re: Python and database unittests

2008-08-27 Thread Marco Bizzarri
On Wed, Aug 27, 2008 at 4:55 AM, alex23 <[EMAIL PROTECTED]> wrote: > Daniel <[EMAIL PROTECTED]> wrote: >> Does anyone know about a module that acts as a database stub for >> python unittests? > > It's not database-specific, but the Mock module should help you here: > > http://python-mock.sourceforg

Re: Python and database unittests

2008-08-27 Thread Marco Bizzarri
On Tue, Aug 26, 2008 at 11:35 PM, Daniel <[EMAIL PROTECTED]> wrote: > Hello, > > I'm writing an application that interacts with a database. As I think > about how to write the unittests, I want them to be able to run > without actually having to access a live database. The pattern that > best des

Re: Tkinter Unix and Windows incompatibility

2008-08-27 Thread Eric Brunel
On Wed, 27 Aug 2008 06:50:30 +0200, akineko <[EMAIL PROTECTED]> wrote: Hello everyone, I'm trying to create custom Tkinter/Pmw widgets for my project. After testing my widgets under Unix (Solaris), I have tried them under Windows and I got a surprise. The widgets came out differently. The follo

Re: unexpected from/import statement behaviour

2008-08-27 Thread Peter Otten
nisp wrote: > Hi all ! > > I'm trying to capture stderr of an external module I use in my python > program. I'm doing this > by setting up a class in my module overwriting the stderr file object > method write. > The external module outputs to stderr this way: > > from sys import std err > > ..

Re: Date Comparison and Manipulation Functions?

2008-08-27 Thread John Machin
On Aug 27, 11:24 am, "W. eWatson" <[EMAIL PROTECTED]> wrote: > John Machin wrote: > > On Aug 27, 10:21 am, "W. eWatson" <[EMAIL PROTECTED]> wrote: > >> I'm using IDLE for Python 2.4, and put pfydate distribution in > >> C:\Python24\Lib\site-packages\pfydate, as required by the > >> page. > >> How

Memory Error

2008-08-27 Thread Sibtey Mehdi
I am using the cPickle module to serialization and de-serialization of heavy python object (80 MB). When I try to save the object it gives the memory Error. Any one can help me out of this problem. I am pickling the object as: def savePklFile(pickleFile, data): pickledFile =

Re: Newbie needs help

2008-08-27 Thread Marco Bizzarri
On Tue, Aug 26, 2008 at 8:33 PM, frankrentef <[EMAIL PROTECTED]> wrote: > > Would the second file need something akin to... > > loginout.admin (ie,url,adminlogin) Yes. Since you're importing the whole module. -- Marco Bizzarri http://iliveinpisa.blogspot.com/ -- http://mail.python.org/mailman

Re: Non-evil multithreaded WSGI server?

2008-08-27 Thread Gerhard Häring
Gabriel Genellina wrote: En Tue, 26 Aug 2008 03:20:53 -0300, Gerhard Häring <[EMAIL PROTECTED]> escribi�: In a recent experiment I've done this: from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from wsgiref.simple_server import make_server, demo_app from SocketServer import Threa

Re: Usual practice: running/testing modules in a package

2008-08-27 Thread Casey
On Aug 12, 9:57 pm, alito <[EMAIL PROTECTED]> wrote: > > A wrapper on the level up works: > > ~/python$ cat importercaller.py > from testpackage import config > config.hello() > > ~/python$ python importercaller.py > hello > > So, how do I run these modules without writing a wrapper script for > ea

Re: Python and database unittests

2008-08-27 Thread Simon Brunning
2008/8/27 alex23 <[EMAIL PROTECTED]>: > Daniel <[EMAIL PROTECTED]> wrote: > It's not database-specific, but the Mock module should help you here: > > http://python-mock.sourceforge.net/ > > There's even an example on that page for mocking a database. There's a number of mocking modules for Python

Re: Python and database unittests

2008-08-27 Thread Simon Brunning
2008/8/27 Marco Bizzarri <[EMAIL PROTECTED]>: > I strongly disagree on using mocks for a database; checking sequences > of SQL statement is fragile, painful, and leads you to frustration > when the actual SQL and the generated SQL do not match. Clearly you need integration tests as well as unit te

Re: Memory Leak?

2008-08-27 Thread Rob Wolfe
Kevin McKinley napisał(a): > So i've complete my first program with a GUI interface. I've noticed > that everytime i click a tab or button the amount of memory the program > takes up goes up by 50-200 kb. The program will start off at 4.5mb and > by the time i'm done it can get up over 10 or 1

Re: ctypes: loading .so file on Linux

2008-08-27 Thread Uwe Schmitt
On 27 Aug., 07:03, Paddy <[EMAIL PROTECTED]> wrote: > On Aug 23, 2:33 pm, Paddy <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > I am am falling at the first hurdle when trying to access a library > > using ctypes. > > > I have a file libucdb.so which the file command says is shared object, > > but I c

Re: Python and database unittests

2008-08-27 Thread Marco Bizzarri
On Wed, Aug 27, 2008 at 10:26 AM, Simon Brunning <[EMAIL PROTECTED]> wrote: > 2008/8/27 Marco Bizzarri <[EMAIL PROTECTED]>: >> I strongly disagree on using mocks for a database; checking sequences >> of SQL statement is fragile, painful, and leads you to frustration >> when the actual SQL and the g

Re: logging exceptions

2008-08-27 Thread Vinay Sajip
On Aug 26, 10:36 am, Alexandru Mosoi <[EMAIL PROTECTED]> wrote: > why doesn'tloggingthrow any exception when it should? how do I > configureloggingto throw exceptions? > > >>> try: > > ... logging.fatal('asdf %d', '123') > ... except: > ... print 'this line is never printed' > ... > Traceback (

Re: libxml2dom - parsing maligned html

2008-08-27 Thread Paul Boddie
On 26 Aug, 23:22, "bruce" <[EMAIL PROTECTED]> wrote: > > ok, i can somehow live with this, i can accommodate it. but tell me, when > the parse module/class for libxml2dom does its thing, why does it not go > forward on the tree when it comes to a , if there's more text in the > string to process???

Re: 've collected huge source codes collection of any kinds

2008-08-27 Thread nntpman68
Albertos wrote: Hello, I've collected huge source codes collection of any kinds : work with text files, database, GUI etc. You can download it here http://freactor.com/get.php?file=Python+source+code First: Learn English Second: In how many news groups did you post (just changing the 'file=..

Re: Launch an application and continue the script's execution

2008-08-27 Thread Tim Golden
Gabriel Genellina wrote: Start the application in a separate console (using `start "" bat_file` might be the easiest way) and then, within your Python script, wait until the new process is ready. The wmi module by Tim Golden can help e.g. wait unt

Re: Inspecting the Instance Vars in a class/object - How?

2008-08-27 Thread Diez B. Roggisch
BrendanC wrote: > I'm trying to understand reflection/introspection in Python. How can I > identify the the type of attribute (e.g. instance var) in a class? > The following returns all the class attributes (methods and instance > vars). > > However I'm interested in identifying the type of value

Re: Date type in win32com?

2008-08-27 Thread Tim Golden
Haeyoung Kim wrote: Hi. I'm migrating a VBScript into python. How should I convert Date type parameter in VBScript's COM interface with win32com? I couldn't find any answer yet... Could you give an example of code you're trying to translate? Normally it's quite simple, but different subsyste

Re: Date Comparison and Manipulation Functions?

2008-08-27 Thread W. eWatson
John Machin wrote: On Aug 27, 11:24 am, "W. eWatson" <[EMAIL PROTECTED]> wrote: John Machin wrote: On Aug 27, 10:21 am, "W. eWatson" <[EMAIL PROTECTED]> wrote: I'm using IDLE for Python 2.4, and put pfydate distribution in C:\Python24\Lib\site-packages\pfydate, as required by the page. How to

Re: logging - how to use in a library?

2008-08-27 Thread Vinay Sajip
On Aug 26, 8:05 pm, Thomas Heller <[EMAIL PROTECTED]> wrote: > I'm using theloggingmodule in my comtypes library to log > 'interesting' things that happen. In other words, the idea > is if the user of the library is interested in the details that > happen in the package internally, he (she?) would

Re: Creating environment variables.

2008-08-27 Thread Fredrik Lundh
aditya shukla wrote: I am writing a program(prog 1) in python , which requires to know the path of another program(prog 2) in order to execute.I can get my prog1 to work when i hard code the path of the existing program(prog2).But since the path of prog could be anywhere on the file system , t

Re: logging exceptions

2008-08-27 Thread Rob Wolfe
Vinay Sajip napisał(a): > On Aug 26, 10:36 am, Alexandru Mosoi <[EMAIL PROTECTED]> wrote: > > why doesn'tloggingthrow any exception when it should? how do I > > configureloggingto throw exceptions? > > > > >>> try: > > > > ... logging.fatal('asdf %d', '123') > > ... except: > > ... print 'thi

Re: iterparse and unicode

2008-08-27 Thread Fredrik Lundh
George Sakkis wrote: if you meant to write "encode", you can indeed safely do [s.encode('utf8') for s in strings] as long as all strings are returned by an ET implementation. I was replying to the general assertion that "in 2.x ASCII byte strings and unicode strings are compatible", not specif

Re: Decorators using instance variables

2008-08-27 Thread Fredrik Lundh
Robert Kaplan wrote: Actually, I found his response to the point, his sample code helpful, and his solution similar to yours. given how your original code looked and how pointless it was, are you sure you're not just another alias for the same guy? -- http://mail.python.org/mailman/listin

use of Queue

2008-08-27 Thread Alexandru Mosoi
how is Queue intended to be used? I found the following code in python manual, but I don't understand how to stop consumers after all items have been produced. I tried different approaches but all of them seemed incorrect (race, deadlock or duplicating queue functionality) def worker():

Re: atomic increment

2008-08-27 Thread Fredrik Lundh
Frank Millman wrote: Just out of interest, would the following, without a lock, be safe? old, atomic_int = atomic_int, atomic_int+1 nope. there's some information here (make sure you read the comments): http://effbot.org/pyfaq/what-kinds-of-global-value-mutation-are-thread-safe.htm and som

Re: use of Queue

2008-08-27 Thread Diez B. Roggisch
Alexandru Mosoi wrote: > how is Queue intended to be used? I found the following code in python > manual, but I don't understand how to stop consumers after all items > have been produced. I tried different approaches but all of them > seemed incorrect (race, deadlock or duplicating queue functio

Syntax error in ".py" file and globals variable values not available.

2008-08-27 Thread Alexis Boutillier
Hi, I have a strange behaviour of python with pdb and import statement. Here is the example code : file my1.py: import my2 file my2.py: a=5 toto I intentionnaly put a syntax error in file my2.py. If I run "python -i my2.py" and run pdb I got : NameError: name 'toto' is not defined >>> import

Re: use of Queue

2008-08-27 Thread Gerhard Häring
Alexandru Mosoi wrote: how is Queue intended to be used? I found the following code in python manual, but I don't understand how to stop consumers after all items have been produced. I tried different approaches but all of them seemed incorrect (race, deadlock or duplicating queue functionality)

Re: What is class method?

2008-08-27 Thread Bruno Desthuilliers
Medardo Rodriguez (Merchise Group) a écrit : On Tue, Aug 26, 2008 at 4:10 PM, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: In Python, there's *no* relationship between classmethods and metaclasses. In OOP the concept of meta-class has everything to do with class methods, regardless if is in

Re: Decorators using instance variables

2008-08-27 Thread Ben Finney
Fredrik Lundh <[EMAIL PROTECTED]> writes: > Robert Kaplan wrote: > > > Actually, I found his response to the point, his sample code > > helpful, and his solution similar to yours. > > given how your original code looked and how pointless it was, are > you sure you're not just another alias for t

Understanding this generator function

2008-08-27 Thread Hussein B
Hey, This is an example of a generator function: = def counter(start_at=0): count = start_at while True: val = (yield count) if val is not None: count = val else: count += 1 == >>> count = counter(5) >>> count.next() 5 >>> count.send(9

Re: use of Queue

2008-08-27 Thread skip
Diez> Put a sentinel into the queue that gets interpreted as "terminate" Diez> for the workers. You need of course to put it in there once for Diez> each worker. Or make the consumers daemon threads so that when the producers are finished an all non-daemon threads exit, the consumers

Re: unexpected from/import statement behaviour

2008-08-27 Thread nisp
On Aug 27, 9:56 am, Peter Otten <[EMAIL PROTECTED]> wrote: > nisp wrote: > > Hi all ! > > > I'm trying to capture stderr of an external module I use in my python > > program. I'm doing this > > by setting up a class in my module overwriting the stderr file object > > method write. > > The external

Re: logging - how to use in a library?

2008-08-27 Thread Thomas Heller
Vinay Sajip schrieb: > Suppose a user of logging configures it wrongly by mistake, so that > there are no handlers configured. In this case, if the logging system > were not to output anything at all, then you would have no information > at all about why - leading to a longer time to diagnose the

Re: Python and database unittests

2008-08-27 Thread M.-A. Lemburg
On 2008-08-26 23:35, Daniel wrote: > Hello, > > I'm writing an application that interacts with a database. As I think > about how to write the unittests, I want them to be able to run > without actually having to access a live database. The pattern that > best describes this is here: > > http:/

How can this script fail?

2008-08-27 Thread [EMAIL PROTECTED]
Hello, it's still me, being unable to load certain modules (for instance, odbc) in scripts that run though IDLE. I've now written a self- containing script that illustrates the whole problem: -- import sys, os # find odbc module in Python distribution tree: for ro

import error between 2 modules

2008-08-27 Thread jimgardener
I am new to python,and am learning from the tutorials i created 2 .py files like below and put the main in one of them empmodule.py -- from workmodule import Worker class Employer: def __init__(self,n): self.name=n self.worker=Worker() def getemployerName(self):

Re: use of Queue

2008-08-27 Thread skip
skip> Or make the consumers daemon threads so that when the producers skip> are finished an all non-daemon threads exit, the consumers do as skip> well. Forget that I wrote this. If they happen to be working on the token they've consumed at the time the other threads exit, they will

Re: Memory Leak

2008-08-27 Thread Kevin McKinley
Kevin McKinley napisał(a): >> that everytime i click a tab or button the amount of memory the program >> takes up goes up by 50-200 kb. The program will start off at 4.5mb and >> by the time i'm done it can get up over 10 or 15 mb. The program will >> start ru

Re: Understanding this generator function

2008-08-27 Thread Ben Finney
Hussein B <[EMAIL PROTECTED]> writes: > This is an example of a generator function [using coroutine > behaviour]: […] > I'm not able to understand how this generator function is working, > would you please me (what happens when calling next/send)? The behaviour you're seeing was introduced in PE

Re: Understanding this generator function

2008-08-27 Thread James Mills
Hi, There is a great set of slides on this topic available here: http://www.dabeaz.com/generators/ They explain this concept quite well and walk you through everything you need to know about generators and how powerful they can be. Please read it. cheers James On 8/27/08, Hussein B <[EMAIL PRO

Re: How can this script fail?

2008-08-27 Thread M.-A. Lemburg
On 2008-08-27 12:37, [EMAIL PROTECTED] wrote: > Hello, > > it's still me, being unable to load certain modules (for instance, > odbc) in scripts that run though IDLE. I've now written a self- > containing script that illustrates the whole problem: I don't think this is related to IDLE or your set

Re: How can this script fail?

2008-08-27 Thread [EMAIL PROTECTED]
On Aug 27, 1:08 pm, "M.-A. Lemburg" <[EMAIL PROTECTED]> wrote: > I don't think this is related to IDLE or your setup. The odbc > module is very old and unmaintained, so it's possible that Windows > doesn't find some system DLLs needed for it to work. Please note that 1) I can type "import odbc" d

finding out the number of rows in a CSV file

2008-08-27 Thread SimonPalmer
anyone know how I would find out how many rows are in a csv file? I can't find a method which does this on csv.reader. Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list

Re: SocketServer max connections

2008-08-27 Thread Laszlo Nagy
Guilherme Polo wrote: On Mon, Aug 25, 2008 at 7:20 AM, Ken Seehart <[EMAIL PROTECTED]> wrote: I'm using SocketServer to implement a local server that serves comet long-polling connections. How do I increase the maximum number of open connections? Currently it is limited to about 8 I think.

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Simon Brunning
2008/8/27 SimonPalmer <[EMAIL PROTECTED]>: > anyone know how I would find out how many rows are in a csv file? > > I can't find a method which does this on csv.reader. len(list(csv.reader(open('my.csv' -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ -- http://

Re: Decorators using instance variables

2008-08-27 Thread Bruno Desthuilliers
Robert Kaplan a écrit : Bruno Desthuilliers a écrit : <...> 2/ don't bother reading anything from someone named 'castironpi', it's one of our currently active resident troll, and he is worse than clueless. Actually, I found his response to the point, his sample code helpful, and his so

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Jon Clements
On Aug 27, 12:16 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > anyone know how I would find out how many rows are in a csv file? > > I can't find a method which does this on csv.reader. > > Thanks in advance You have to iterate each row and count them -- there's no other way without supporting info

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Jon Clements
On Aug 27, 12:29 pm, "Simon Brunning" <[EMAIL PROTECTED]> wrote: > 2008/8/27 SimonPalmer <[EMAIL PROTECTED]>: > > > anyone know how I would find out how many rows are in a csv file? > > > I can't find a method which does this on csv.reader. > > len(list(csv.reader(open('my.csv' > > -- > Cheers,

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Simon Brunning
2008/8/27 Jon Clements <[EMAIL PROTECTED]>: >> len(list(csv.reader(open('my.csv' > Not the best of ideas if the row size or number of rows is large! > Manufacture a list, then discard to get its length -- ouch! I do try to avoid premature optimization. ;-) -- Cheers, Simon B. -- http://mai

Re: use of Queue

2008-08-27 Thread Alexandru Mosoi
On Aug 27, 1:06 pm, Gerhard Häring <[EMAIL PROTECTED]> wrote: > Alexandru Mosoi wrote: > > how is Queue intended to be used? I found the following code in python > > manual, but I don't understand how to stop consumers after all items > > have been produced. I tried different approaches but all of

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread SimonPalmer
On Aug 27, 12:41 pm, Jon Clements <[EMAIL PROTECTED]> wrote: > On Aug 27, 12:29 pm, "Simon Brunning" <[EMAIL PROTECTED]> > wrote: > > > 2008/8/27 SimonPalmer <[EMAIL PROTECTED]>: > > > > anyone know how I would find out how many rows are in a csv file? > > > > I can't find a method which does this

Re: use of Queue

2008-08-27 Thread Jeff
> Your solution works assuming that you know how many consumer threads > you have :). I don't :). More than that, it's not correct if you have > more than one producer :). Having a sentinel was my very first idea, > but as you see... it's a race condition (there are cases in which not > all items a

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread SimonPalmer
On Aug 27, 12:50 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > On Aug 27, 12:41 pm, Jon Clements <[EMAIL PROTECTED]> wrote: > > > > > On Aug 27, 12:29 pm, "Simon Brunning" <[EMAIL PROTECTED]> > > wrote: > > > > 2008/8/27 SimonPalmer <[EMAIL PROTECTED]>: > > > > > anyone know how I would find out how

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Jon Clements
On Aug 27, 12:48 pm, "Simon Brunning" <[EMAIL PROTECTED]> wrote: > 2008/8/27 Jon Clements <[EMAIL PROTECTED]>: > > >> len(list(csv.reader(open('my.csv' > > Not the best of ideas if the row size or number of rows is large! > > Manufacture a list, then discard to get its length -- ouch! > > I do

Re: Understanding this generator function

2008-08-27 Thread Jeff
> def counter(start_at=0): >     count = start_at >     while True: >         val = (yield count) A generator can accept a value from the consumer. So, If I have a counter: c = counter() I can send it a value: c.send(9) >         if val is not None: >             count = val The generato

Re: use of Queue

2008-08-27 Thread Alexandru Mosoi
On Aug 27, 2:54 pm, Jeff <[EMAIL PROTECTED]> wrote: > Queue raises an Empty exception when there are no items left in the > queue.  Put the q.get() call in a try block and exit in the except > block. Wrong. What if producer takes a long time to produce an item? Consumers will find the queue empty

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread Jon Clements
On Aug 27, 12:54 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > On Aug 27, 12:50 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > > > > > On Aug 27, 12:41 pm, Jon Clements <[EMAIL PROTECTED]> wrote: > > > > On Aug 27, 12:29 pm, "Simon Brunning" <[EMAIL PROTECTED]> > > > wrote: > > > > > 2008/8/27 SimonPa

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread John Machin
On Aug 27, 9:54 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > On Aug 27, 12:50 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > > > > > On Aug 27, 12:41 pm, Jon Clements <[EMAIL PROTECTED]> wrote: > > > > On Aug 27, 12:29 pm, "Simon Brunning" <[EMAIL PROTECTED]> > > > wrote: > > > > > 2008/8/27 SimonPal

Re: use of Queue

2008-08-27 Thread Alexandru Mosoi
On Aug 27, 12:45 pm, Alexandru Mosoi <[EMAIL PROTECTED]> wrote: > how is Queue intended to be used? I found the following code in python > manual, but I don't understand how to stop consumers after all items > have been produced. I tried different approaches but all of them > seemed incorrect (rac

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread SimonPalmer
On Aug 27, 1:15 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Aug 27, 9:54 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > > > > > On Aug 27, 12:50 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > > > > On Aug 27, 12:41 pm, Jon Clements <[EMAIL PROTECTED]> wrote: > > > > > On Aug 27, 12:29 pm, "Simon Br

Re: import error between 2 modules

2008-08-27 Thread Laszlo Nagy
jimgardener wrote: I am new to python,and am learning from the tutorials i created 2 .py files like below and put the main in one of them empmodule.py -- from workmodule import Worker class Employer: def __init__(self,n): self.name=n self.worker=Worker() def gete

Re: use of Queue

2008-08-27 Thread Diez B. Roggisch
> > Your solution works assuming that you know how many consumer threads > you have :). I don't :). More than that, it's not correct if you have > more than one producer :). Having a sentinel was my very first idea, > but as you see... it's a race condition (there are cases in which not > all item

Re: unexpected from/import statement behaviour

2008-08-27 Thread Diez B. Roggisch
nisp wrote: > On Aug 27, 9:56 am, Peter Otten <[EMAIL PROTECTED]> wrote: >> nisp wrote: >> > Hi all ! >> >> > I'm trying to capture stderr of an external module I use in my python >> > program. I'm doing this >> > by setting up a class in my module overwriting the stderr file object >> > method wr

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread TYR
Use csv.DictReader to get a list of dicts (you get one for each row, with the values as the vals and the column headings as the keys) and then do a len(list)? -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorators using instance variables

2008-08-27 Thread Paul Boddie
On 27 Aug, 13:32, Bruno Desthuilliers wrote: > > This _sometimes_ happens, yes, and that's why you just shouldn't trust > him : unless you have a good knowledge of the topic, you just can't tell > whether his answer is ok or total rubbish. Can everyone just be done graduating from high school and

Re: unexpected from/import statement behaviour

2008-08-27 Thread nisp
On Aug 27, 2:43 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > nisp wrote: > > On Aug 27, 9:56 am, Peter Otten <[EMAIL PROTECTED]> wrote: > >> nisp wrote: > >> > Hi all ! > > >> > I'm trying to capture stderr of an external module I use in my python > >> > program. I'm doing this > >> > by set

ANN: Pyrex 0.9.8.5

2008-08-27 Thread greg
Pyrex 0.9.8.5 is now available: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ Various minor bug fixes and improvements. What is Pyrex? -- Pyrex is a language for writing Python extension modules. It lets you freely mix operations on Python and C data, with all Python

Re: logging exceptions

2008-08-27 Thread Vinay Sajip
On Aug 27, 10:30 am, Rob Wolfe <[EMAIL PROTECTED]> wrote: > Vinay Sajip napisa³(a): > > > > > On Aug 26, 10:36 am, Alexandru Mosoi <[EMAIL PROTECTED]> wrote: > > > why doesn'tloggingthrow any exception when it should? how do I > > > configureloggingto throw exceptions? > > > > >>> try: > > > > ...

Python multimap

2008-08-27 Thread brad
Recently had a need to us a multimap container in C++. I now need to write equivalent Python code. How does Python handle this? k['1'] = 'Tom' k['1'] = 'Bob' k['1'] = 'Joe' ... Same key, but different values. No overwrites either They all must be inserted into the container Thanks, Brad

Re: logging - how to use in a library?

2008-08-27 Thread Vinay Sajip
On Aug 27, 11:28 am, Thomas Heller <[EMAIL PROTECTED]> wrote: > Vinay Sajip schrieb: > > I came up with a workaround that seems to do what I want. I add a NULL > handler > to my top-level logger which is not the root logger but a logger named > 'comtypes', > other loggers are named 'comtypes.som

Re: unexpected from/import statement behaviour

2008-08-27 Thread Peter Otten
nisp wrote: > Thanks first of all ! I read the interesting Diez's link but something > still remains to me unclear, on the other hand it's clear the my > problem is concentrated there and on symbols. Read it again. If you have two modules module1.py from sys import stderr module2.py from module

Re: JSON from Python mysqldb

2008-08-27 Thread TYR
There's always the naive option. query = ('species', 'lifestyle', 'coolness', 'tentacles=>8') db.execute('SELECT %s, %s, %s % FROM creatures WHERE %s;' % query) record = dict(zip((query), (db.fetchall())) array = '''{ ''' for k,v in record: array.append('"(k)":"(v)"') array.append('

How to update value in dictionary?

2008-08-27 Thread ssecorp
dict.update({"a":1}) SETS the dict item "a" 's value to 1. i want to increase it by 1. isnt that possible in an easy way? I should use a tuple for this? -- http://mail.python.org/mailman/listinfo/python-list

Re: JSON from Python mysqldb

2008-08-27 Thread TYR
On Aug 27, 2:37 pm, TYR <[EMAIL PROTECTED]> wrote: > There's always the naive option. > > query = ('species', 'lifestyle', 'coolness', 'tentacles=>8') > db.execute('SELECT %s, %s, %s % FROM creatures WHERE %s;' % query) > record = dict(zip((query), (db.fetchall())) > array = '''{ >              '''

Re: How to update value in dictionary?

2008-08-27 Thread Iain King
On Aug 27, 2:40 pm, ssecorp <[EMAIL PROTECTED]> wrote: > dict.update({"a":1}) SETS the dict item "a" 's value to 1. > > i want to increase it by 1. isnt that possible in an easy way? I > should use a tuple for this? dict["a"] += 1 Iain -- http://mail.python.org/mailman/listinfo/python-list

Re: How to update value in dictionary?

2008-08-27 Thread Diez B. Roggisch
ssecorp wrote: > dict.update({"a":1}) SETS the dict item "a" 's value to 1. > > i want to increase it by 1. isnt that possible in an easy way? I > should use a tuple for this? 1) Don't use dict as name for a dictionary, it shadows the type dict 2) setdefault is your friend d = {} d['a'] = d.s

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread Peter Otten
Jon Clements wrote: > On Aug 27, 12:54 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: >> after reading the file throughthe csv.reader for the length I cannot >> iterate over the rows. How do I reset the row iterator? > > If you're sure that the number of rows is always less than 200. Or 2000. Or 2

Re: Python multimap

2008-08-27 Thread Mike Kent
On Aug 27, 9:35 am, brad <[EMAIL PROTECTED]> wrote: > Recently had a need to us a multimap container in C++. I now need to > write equivalent Python code. How does Python handle this? > > k['1'] = 'Tom' > k['1'] = 'Bob' > k['1'] = 'Joe' > ... > > Same key, but different values. No overwrites either

Re: GUI programming with python

2008-08-27 Thread rynt
On Aug 26, 10:49 am, John Fabiani <[EMAIL PROTECTED]> wrote: > Alan Franzoni wrote: > > zamil was kind enough to say: > > > [cut] > > > See the following link on the Python website. http://wiki.python.org/moin/GuiProgramming Google this list for GUI RC -- http://mail.python.org/mailman/listinf

Re: Python multimap

2008-08-27 Thread Matt Nordhoff
brad wrote: > Recently had a need to us a multimap container in C++. I now need to > write equivalent Python code. How does Python handle this? > > k['1'] = 'Tom' > k['1'] = 'Bob' > k['1'] = 'Joe' > ... > > Same key, but different values. No overwrites either They all must > be inserted into

Re: Python multimap

2008-08-27 Thread Michele Petrazzo
brad wrote: Recently had a need to us a multimap container in C++. I now need to write equivalent Python code. How does Python handle this? k['1'] = 'Tom' k['1'] = 'Bob' k['1'] = 'Joe' Same key, but different values. No overwrites either They all must be inserted into the container

no string.downer() ?

2008-08-27 Thread ssecorp
if i want to make a string downcase, is upper().swapcase() the onyl choice? there is no downer() ? -- http://mail.python.org/mailman/listinfo/python-list

Re: no string.downer() ?

2008-08-27 Thread Guilherme Polo
On Wed, Aug 27, 2008 at 11:16 AM, ssecorp <[EMAIL PROTECTED]> wrote: > if i want to make a string downcase, is upper().swapcase() the onyl > choice? there is no downer() ? There is no "downer" indeed, instead it is named "lower". > -- > http://mail.python.org/mailman/listinfo/python-list > --

Re: use of Queue

2008-08-27 Thread Iain King
On Aug 27, 1:17 pm, Alexandru Mosoi <[EMAIL PROTECTED]> wrote: > On Aug 27, 12:45 pm, Alexandru Mosoi <[EMAIL PROTECTED]> wrote: > > > > > how is Queue intended to be used? I found the following code in python > > manual, but I don't understand how to stop consumers after all items > > have been

Re: no string.downer() ?

2008-08-27 Thread Jon Clements
On Aug 27, 3:16 pm, ssecorp <[EMAIL PROTECTED]> wrote: > if i want to make a string downcase, is upper().swapcase() the onyl > choice? there is no downer() ? lower() You need to be careful ssecorp, you might be at risk of being considered a troll -- always give the benefit though (probably why I'

Re: How to update value in dictionary?

2008-08-27 Thread bearophileHUGS
ssecorp wrote: > dict.update({"a":1}) SETS the dict item "a" 's value to 1. That works but it's not the right way to do that, use this: d["a"] = 1 Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

how do I stop SocketServer()?

2008-08-27 Thread Alexandru Mosoi
supposing that I have a server (an instance of SocketServer()) that waits for a connection (ie is blocked in accept()) and in another thread i want to stop the server, how do I do that? -- http://mail.python.org/mailman/listinfo/python-list

  1   2   3   >