Re: Removing Space and "-" from a string

2008-05-20 Thread Paul Hankin
On May 20, 5:02 pm, "Ahmed, Shakir" <[EMAIL PROTECTED]> wrote: > I have thousands of records in MS Access database table, which records I > am fetching using python script. One of the columns having string like > '8 58-2155-58' > > Desired output: '858215558' > > I want to remove any spaces between

Re: iterate start at second row in file not first

2008-05-20 Thread Paul Hankin
On May 20, 7:34 pm, [EMAIL PROTECTED] wrote: > i have a big file with sentences, the first file of each sentence > contains a colon(:) somewher eon that line > i want to jump past that sentence. > > if all(x != ':' for x in line): > > this way i  can check but i dont want to check for every line in

Running programs under a python program...

2008-05-20 Thread [EMAIL PROTECTED]
So I have a python program that runs a bunch of other programsit then loops forever, occasionally executing other programs. To run each of these programs my python code executes: subprocess.Popen(command_line, shell=True, stdout=fd, stderr=subprocess.STDOUT) where command_line is an appropria

Re: Access to sysctl on FreeBSD?

2008-05-20 Thread Thomas Heller
Skye schrieb: > Great, thanks for the help (I'm fairly new to Python, didn't know > about ctypes) > > from ctypes import * > libc = CDLL("libc.so.7") > size = c_uint(0) > libc.sysctlbyname("net.inet.ip.stats", None, byref(size), None, 0) > buf = c_char_p(" " * size.value) >

Re: Processing in Python

2008-05-20 Thread Diez B. Roggisch
Istvan Albert schrieb: On May 20, 6:13 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: Salvatore DI DI0 schrieb: Hello, The Processing Graphics language has been implemented in Javascript. No, it hasn't. Processing is written in Java. He meant it has been re-implemented in Javascript: ht

Re: persistent deque

2008-05-20 Thread inhahe
> > i don't know how i would get around the problem, though, because i'd have > to know how to access the deque object that my class stores when i do > deque.__init__ in my constructor, so that i could pickle it and my class > variables separately. > > i decided i could just pickle deque(self),

online computer shops

2008-05-20 Thread rema.khan
* Drives & Writers, * Hard Drives & Storage, * Headphones & Mics, * Internet / Internet Telephony, * Keyboards & Mouse, * Memory / RAM, * Memory Card & Readers, * Modems, * TV Tuner Cards, * UPS, * USB Devices, * WebCams, * Wireless Accessories...

Re: default gettext localedir on windows

2008-05-20 Thread ZeeGeek
On May 21, 2:31 am, Thorsten Kampe <[EMAIL PROTECTED]> wrote: > * ZeeGeek (Tue, 20 May 2008 09:31:27 -0700 (PDT)) > > > > > On May 17, 8:39 pm, Thorsten Kampe <[EMAIL PROTECTED]> wrote: > > > * ZeeGeek (Sun, 4 May 2008 10:56:52 -0700 (PDT)) > > > > On May 5, 1:16 am, Thorsten Kampe <[EMAIL PROTECTE

Re: feature proposal, debug on exception

2008-05-20 Thread Ville M. Vainio
Simon Forman <[EMAIL PROTECTED]> writes: > This is not exactly an answer to your proposal, I know, but FWIW > Ipython has exactly this capability. Yes. When you %run a scripts and get exception, you can launch post-mortem pdb on it by typing %debug. -- http://mail.python.org/mailman/listinfo/pyt

Re: Python's doc problems: sort

2008-05-20 Thread alex23
On May 21, 8:53 am, Xah Lee <[EMAIL PROTECTED]> wrote: > The complaint about python doc has turned up > now and then in the past few years it seems, but always got put down > by python priests No, what was generally rejected was the idea that *you* could bring more clarity to the documentation, ba

Re: Removing Space and "-" from a string

2008-05-20 Thread inhahe
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Shakir, > >> I have thousands of records in MS Access database table, which records I >> am fetching using python script. One of the columns having string like >> '8 58-2155-58' >> >> Desired output: '858215558' >> >> I want to remove

Re: feature proposal, debug on exception

2008-05-20 Thread alex23
On May 21, 10:59 am, Paul Rubin wrote: > I'd like to propose that debug-on-exception be made into a standard > feature that is easy to enable, e.g. with a command line option > or with a simple pdb call immediately after the import: Forgive me if I've missed your point,

Re: Using Python for programming algorithms

2008-05-20 Thread Paddy
On May 17, 11:32 pm, Vicent Giner <[EMAIL PROTECTED]> wrote: > Hello. > > I am new to Python. It seems a very interesting language to me. Its > simplicity is very attractive. > > However, it is usually said that Python is not a compiled but > interpreted programming language —I mean, it is not like

Re: What's wrong with that comment?

2008-05-20 Thread Ludwig Miniatur
On 21 Mai, 00:12, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 20 May 2008 16:22:10 -0300, Joe P. Cool > <[EMAIL PROTECTED]> escribió: > > > > > Ludwig Miniatur wrote: > >> For example: > >> #!/usr/bin/env python > > >> from parser import suite, ast2list > >> fh = file(__file__) > >> s

Re: Using Python for programming algorithms

2008-05-20 Thread Paddy
On May 19, 8:09 pm, Lou Pecora <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Roel Schroeven <[EMAIL PROTECTED]> wrote: > > > > > Bruno Desthuilliers schreef: > > > 1/ being interpreted or compiled (for whatever definition of these > > > terms) is not a property of a language, but

Re: Using Python for programming algorithms

2008-05-20 Thread Kay Schluehr
On 18 Mai, 00:32, Vicent Giner <[EMAIL PROTECTED]> wrote: > Maybe this is not the right forum, but maybe you can give me some > hints or tips... > > Thank you in advance. If Python doesn't run in production systems execution speed doesn't matter much. What actually matters when *developing* non-t

Re: feature proposal, debug on exception

2008-05-20 Thread Simon Forman
On May 20, 5:59 pm, Paul Rubin wrote: > There's an occasional question here about how to get python to launch > pdb on encountering an uncaught exception. The answer is to look in > some ASPN recipe and do some weird magic. I guess that works, but > it's another thing t

Re: Misuse of list comprehensions?

2008-05-20 Thread Simon Forman
On May 20, 8:58 am, Paul McGuire <[EMAIL PROTECTED]> wrote: > On May 20, 10:50 am, [EMAIL PROTECTED] wrote: > > > > > You don't need all those conditionals. A set differs from a list > > precisely in the fact that each element is unique. And since the > > function is expecting "s" to be an iterable

Re: Struct usage and varying sizes of h, l, etc

2008-05-20 Thread Dan Bishop
On May 20, 5:59 pm, Robert Kern <[EMAIL PROTECTED]> wrote: > Ethan Furman wrote: > > Greetings, > > > I'm looking at the struct module for binary packing of ints and floats.   > > The documentation refers to C datatypes.  It's been many years since I > > looked at C, but I seem to remember that the

Port scan module

2008-05-20 Thread zerge69
I programmed a port scanning module which you can download here http://code.google.com/p/portscan/ Including the module in your program allows you to scan specific ports in an IP, using the function scan(ip,port,timeout). Instead of getting a cryptic code in return, the function will return "open"

Re: Newbie In Python

2008-05-20 Thread zerge69
On May 20, 5:15 am, [EMAIL PROTECTED] wrote: > I have Heard About "Python" its a OOD Language. i have to Learn it > where from i should start it. > i have python compiler at linux Platform. > anyone can suggest me about it. > > Thanks In advance. I recommend Pyscripter http://code.google.com/p/pys

Re: namespaces and eval

2008-05-20 Thread George Sakkis
On May 16, 5:02 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] writes: > > Sorry for the repost, didnt' quite finish > > > Suppose I have a function in module X that calls eval e.g, > > > X.py > > ___ > > Def foo(bar): > >         Eval(bar) > > ___ > > > Now eval will b

Re: Code/test ratio wrt static vs dynamic typing

2008-05-20 Thread Ben Finney
greg <[EMAIL PROTECTED]> writes: > Also, I don't think it's valid to equate the size of the tests with > the amount of effort it took to develop them. For instance, the test > suite for Pyrex is currently larger than the Pyrex compiler, but > I've still spent far more time and effort developing th

Re: Code/test ratio wrt static vs dynamic typing [was: Re: Python Success stories]

2008-05-20 Thread greg
Someone wrote: I'm just curious whether this argument against dynamic typing - that you end up doing the job of a static compiler in test code - holds in practice. I suspect that, although some of the things caught by the tests would be caught by static typing, the very *same* tests are also ca

Re: persistent deque

2008-05-20 Thread inhahe
oh yeah! thanks for pointing it out, i should have thought of that, i *just* read about it today, or was it yesterday. so what's the problem with pickle? i have a feeling, maybe i read it, that when you pickle a derived class it pickles it as a member of the base class, is that it? i don't k

Re: Python's doc problems: sort

2008-05-20 Thread Xah Lee
I offer the python community complete rewrite of the Python doc. The resulting doc would be one of the best technical writing among Open Source community's documentations. (a fair verification can be obtained by polling professional writers and editor community, e.g. staff writers of Time Mag or ot

Re: Python and Flaming Thunder

2008-05-20 Thread Collin
Dave Parker wrote: I've read that one of the design goals of Python was to create an easy- to-use English-like language. That's also one of the design goals of Flaming Thunder at http://www.flamingthunder.com/ , which has proven easy enough for even elementary school students, even though it is

Re: iterate start at second row in file not first

2008-05-20 Thread Scott David Daniels
Mark d. wrote: How about: mov = open(afile) line = mov.readline() ...(process your ':' line) for line in mov.readlines(): ... The problem here is that you read the entire file in in the call to readlines. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/py

Re: Misuse of list comprehensions?

2008-05-20 Thread Colin J. Williams
John Salerno wrote: I posted this code last night in response to another thread, and after I posted it I got to wondering if I had misused the list comprehension. Here's the two examples: Example 1: def compress(s): new = [] for c in s: if c not in new:

Re: Using StringVars in List of Dictionaries as tkInter variables for Scale and Label widgets

2008-05-20 Thread seanacais
On May 20, 2:40 am, Peter Otten <[EMAIL PROTECTED]> wrote: > seanacais wrote: > > You have to ensure that the lines > > from Tkinter import * > root = Tk() > > are *executed* before the line > > dname = dict((d, StringVar()) for d in OPDefaults) > > Peter > > PS: If you still can't fix your script,

Re: Misuse of list comprehensions?

2008-05-20 Thread Larry Bates
John Salerno wrote: I posted this code last night in response to another thread, and after I posted it I got to wondering if I had misused the list comprehension. Here's the two examples: Example 1: def compress(s): new = [] for c in s: if c not in new:

feature proposal, debug on exception

2008-05-20 Thread Paul Rubin
There's an occasional question here about how to get python to launch pdb on encountering an uncaught exception. The answer is to look in some ASPN recipe and do some weird magic. I guess that works, but it's another thing to remember or keep looking up when the occasion arises (some program cras

Re: Removing Space and "-" from a string

2008-05-20 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: Shakir, I have thousands of records in MS Access database table, which records I am fetching using python script. [A] columns has strings like '8 58-2155-58' Desired output: '858215558' input = '8 58-2155-58' output = ''.join( [ c for c in input if c not in ' -' ] ) ou

Re: Misuse of list comprehensions?

2008-05-20 Thread Colin J. Williams
Colin J. Williams wrote: John Salerno wrote: I posted this code last night in response to another thread, and after I posted it I got to wondering if I had misused the list comprehension. Here's the two examples: Example 1: def compress(s): new = [] for c in s:

Re: Using Python for programming algorithms

2008-05-20 Thread sturlamolden
On May 20, 3:37 pm, brad <[EMAIL PROTECTED]> wrote: > seen this first hand. Getting results back the same day or sooner may be > important. In cases such as this, I use C or C++... nothing else will > do. Nothing else is as fast. Right. Tell that to the Fortran community. And by the way: http://

Re: persistent deque

2008-05-20 Thread Larry Bates
inhahe wrote: def __init__(self, filename, initial): should be def __init__(self, filename, initial=[]): (that was the whole reason i put the filename first.) sorry. Defaulting initial to empty list this way is asking for trouble. You should default it to None and check for None and

Re: Processing in Python

2008-05-20 Thread kib
A PyQt4 version here : http://dev.nodebox.net/wiki/Qt , but it's really buggy (no one seems to have fixed it till 5 months). There's even a PyGtk clone of NodeBox here : http://shoebox.sollec.org/ I'll be happy to work on one of these projects, see you : Kib. -- http://mail.python.org/mailman

Re: What is wrong with my Python threading?

2008-05-20 Thread Eduardo O. Padoan
On Tue, May 20, 2008 at 8:24 PM, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > En Tue, 20 May 2008 10:28:51 -0300, castironpi <[EMAIL PROTECTED]> > escribió: > >> You meant 'thd1.start( )' and 'thd2.start( )'. > > Wow! A message with a high S/N ratio coming from you! > And it's not the first I've

Re: What is wrong with my Python threading?

2008-05-20 Thread Gabriel Genellina
En Tue, 20 May 2008 10:28:51 -0300, castironpi <[EMAIL PROTECTED]> escribió: You meant 'thd1.start( )' and 'thd2.start( )'. Wow! A message with a high S/N ratio coming from you! And it's not the first I've seen - whatever pills you're taking, they're good for you... -- Gabriel Genellina

Re: Embedding Python question.

2008-05-20 Thread Gabriel Genellina
En Tue, 20 May 2008 06:35:23 -0300, Thomas Troeger <[EMAIL PROTECTED]> escribió: I've successfully embedded the Python interpreter into a set of C/C++ application programs that use a larger library project with information from http://docs.python.org/api/api.html and http://docs.python.or

Re: Struct usage and varying sizes of h, l, etc

2008-05-20 Thread Robert Kern
Ethan Furman wrote: Greetings, I'm looking at the struct module for binary packing of ints and floats. The documentation refers to C datatypes. It's been many years since I looked at C, but I seem to remember that the data type sizes were not fixed -- for example, an int might be two byes o

Re: python script to windows exe

2008-05-20 Thread Gabriel Genellina
En Tue, 20 May 2008 04:04:13 -0300, sandeep <[EMAIL PROTECTED]> escribió: thanks for ur replies. i have a bit closer look at my code and i am able to fix the problem.now my exe is working fine.the code is bit more cleaner now as i removed lot of unused function from it and try to document it a

Re: regarding process preemption in linux

2008-05-20 Thread Gabriel Genellina
En Tue, 20 May 2008 01:18:29 -0300, PARIMALA KALAVALA <[EMAIL PROTECTED]> escribió: I am presently working on linux. I wanted to know how to view the preemption of one process by another process. If we give TOP command we are not able to visualize it or do we need to write any different c

Re: Processing in Python

2008-05-20 Thread Istvan Albert
On May 20, 6:13 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Salvatore DI DI0 schrieb: > > > Hello, > > > The Processing Graphics language has been implemented in Javascript. > > No, it hasn't. Processing is written in Java. He meant it has been re-implemented in Javascript: http://ejohn.o

Re: Processing in Python

2008-05-20 Thread Anton Hartl
On 2008-05-20, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > Salvatore DI DI0 schrieb: >> Hello, >> >> The Processing Graphics language has been implemented in Javascript. > > No, it hasn't. Processing is written in Java. Yes, it really has been implemented in Javascript: http://ejohn.org/bl

Re: Misuse of list comprehensions?

2008-05-20 Thread Paul McGuire
On May 20, 11:08 am, Paul Hankin <[EMAIL PROTECTED]> wrote: > On May 20, 3:58 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > > > def compress(s): > >     seen = set() > >     return ''.join(c for c in s if c not in seen and (seen.add(c) or > > True)) > > Slightly nicer is to move the set add out of

Re: Processing in Python

2008-05-20 Thread Diez B. Roggisch
Salvatore DI DI0 schrieb: Hello, The Processing Graphics language has been implemented in Javascript. No, it hasn't. Processing is written in Java. Does anybody tried to make this in Python ? There are similar projects, yet maybe not to the same level of integration. However, pygame + PyO

Re: What's wrong with that comment?

2008-05-20 Thread Gabriel Genellina
En Tue, 20 May 2008 16:22:10 -0300, Joe P. Cool <[EMAIL PROTECTED]> escribió: Ludwig Miniatur wrote: For example: #!/usr/bin/env python from parser import suite, ast2list fh = file(__file__) s = fh.read() fh.close() ast = suite(s) while False: print "hello world" # comment Looks like a lit

Re: persistent deque

2008-05-20 Thread inhahe
def __init__(self, filename, initial): should be def __init__(self, filename, initial=[]): (that was the whole reason i put the filename first.) sorry. -- http://mail.python.org/mailman/listinfo/python-list

Processing in Python

2008-05-20 Thread Salvatore DI DI0
Hello, The Processing Graphics language has been implemented in Javascript. Does anybody tried to make this in Python ? Regards Salvatore http://processing.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Flaming Thunder

2008-05-20 Thread MRAB
On May 20, 4:33 am, Dave Parker <[EMAIL PROTECTED]> wrote: > On May 14, 7:59 pm, John Salerno <[EMAIL PROTECTED]> wrote: > > > Would it be valid to say: > > > x = "concrete" > > > or to say: > > > if command (is) set to "quit" > > > ?? > > I like the idea of: > > If command is set to "quit" ...

Re: Python and Flaming Thunder

2008-05-20 Thread MRAB
On May 20, 4:20 am, Dave Parker <[EMAIL PROTECTED]> wrote: > > > I <[EMAIL PROTECTED]> wrote: > > > Plus, me getting paid to work on Flaming Thunder is far more > > > motivating than me not getting paid to work on Python. > > On May 14, 8:30 pm, John Salerno <[EMAIL PROTECTED]> wrote: > > That's tr

Re: preserve history in the interactive python

2008-05-20 Thread Martin Marcher
Hi, On Tue, May 20, 2008 at 8:19 PM, Nikhil <[EMAIL PROTECTED]> wrote: > Nikhil wrote: >> the previous interactive shell. Basically, is there anyway that I can >> preserve the history in the shell? > > I figured it out. This below thing works fine for me. > BTW, I got it from http://docs.python.or

Re: Misuse of list comprehensions?

2008-05-20 Thread Paddy
On May 20, 3:58 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > On May 20, 8:13 am, "John Salerno" <[EMAIL PROTECTED]> wrote: > > > > > I posted this code last night in response to another thread, and after I > > posted it I got to wondering if I had misused the list comprehension. Here's > > the two

Struct usage and varying sizes of h, l, etc

2008-05-20 Thread Ethan Furman
Greetings, I'm looking at the struct module for binary packing of ints and floats. The documentation refers to C datatypes. It's been many years since I looked at C, but I seem to remember that the data type sizes were not fixed -- for example, an int might be two byes on one machine, and fo

Re: conventions/requirements for 'is' vs '==', 'not vs '!=', etc

2008-05-20 Thread castironpi
On May 20, 11:49 am, [EMAIL PROTECTED] wrote: > On May 20, 9:04 am, castironpi <[EMAIL PROTECTED]> wrote: > > > > > > > On May 20, 5:04 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > > > > John Salerno <[EMAIL PROTECTED]> wrote: > > > a = 'this is longer' > > > b = 'this is longer' > > > >

Re: persistent deque

2008-05-20 Thread inhahe
"castironpi" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'd like a persistent deque, such that the instance operations all > commit atomicly to file system. ok, i made your persistent deque. but there are two important notes regarding this module: 1) I am a genius. 2) it do

Re: self.var hmm?

2008-05-20 Thread Paul Boddie
On 20 Mai, 22:58, [EMAIL PROTECTED] wrote: > class TaskGroup: > def __init__(self): > self.group = [] > > def addTask(self, task): > self.group.append(task) > > is this wrong? i have a program thats too big to post but should i > just do group.append in addTask? No, you hav

Re: List of disk drives on Windows?

2008-05-20 Thread Mike Driscoll
On May 20, 3:43 pm, Christian Heimes <[EMAIL PROTECTED]> wrote: > Mike Driscoll schrieb: > > > > > On May 20, 2:45 pm, Tim Golden <[EMAIL PROTECTED]> wrote: > >> Bob Greschke wrote: > >>> This MUST have been asked before, but I can't seem to Google the right > >>> thing.  How can I get a list of dr

Re: Using Python for programming algorithms

2008-05-20 Thread Aahz
In article <[EMAIL PROTECTED]>, brad <[EMAIL PROTECTED]> wrote: > >Run time is not important until you are asked to scale to millions >or billions of users or computations or large data sets. I've seen >this first hand. Getting results back the same day or sooner may be >important. In cases such a

Re: self.var hmm?

2008-05-20 Thread Martin Marcher
Hi, that's because self.group is not the same as TaskGroup.group quickish: class TaskGroup group = [] def __init__(self): """ ## note that all TaskGroup instances now use the the same self.group """ self.group = TaskGroup.group def addTask(self, task): self.group.app

self.var hmm?

2008-05-20 Thread notnorwegian
class TaskGroup: def __init__(self): self.group = [] def addTask(self, task): self.group.append(task) is this wrong? i have a program thats too big to post but should i just do group.append in addTask? reason is when later doing TaskGroup.group i get None -- http://mail

Re: Report Lab Image Flowable Issue ..

2008-05-20 Thread Robin Becker
dbee wrote: I'm try to generate a report that will span multiple pages and have dynamic content using python reportlab. I have no issues with regards to generating images and then using p.drawInlineImage(signup_img, 100,150) to draw them onto the canvas. The problem that i have comes when i

Re: List of disk drives on Windows?

2008-05-20 Thread Christian Heimes
Mike Driscoll schrieb: > On May 20, 2:45 pm, Tim Golden <[EMAIL PROTECTED]> wrote: >> Bob Greschke wrote: >>> This MUST have been asked before, but I can't seem to Google the right >>> thing. How can I get a list of drives on a Windows box, like ["C:\", >>> "D:\"], like I can if I do something lik

Re: namespaces and eval

2008-05-20 Thread dave
On May 17, 12:20 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] writes: > > On May 16, 2:47 pm, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > >> On 16 mai, 23:23, [EMAIL PROTECTED] wrote: > > >> > Thanks for the responses. I'm well aware that the function can be > >> >

Re: Misuse of list comprehensions?

2008-05-20 Thread John Salerno
"Thomas Bellman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "John Salerno" <[EMAIL PROTECTED]> writes: > >> "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> the above code is pretty much of a no-no because it has quadratic >>> runtime >>> be

Re: scaling problems

2008-05-20 Thread David Stanek
On Tue, May 20, 2008 at 12:03 AM, James A. Donald <[EMAIL PROTECTED]> wrote: > On Mon, 19 May 2008 21:04:28 -0400, "David Stanek" > <[EMAIL PROTECTED]> wrote: >> What is the difference if you have a process with 10 threads or 10 >> separate processes running in parallel? Apache is a good example of

Re: Accumulating values in dictionary

2008-05-20 Thread Zack
On May 20, 10:38 am, Thomas Bellman <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > > from collections import defaultdict > > d = defaultdict(int) # That means the default value will be 0 > > for person in people: > > d[person.fav_food] += 1 > > Ah! I didn't think of

Re: List of disk drives on Windows?

2008-05-20 Thread python
Mensanator, >>> import os.path >>> dl = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' >>> drives = ['%s:' % d for d in dl if os.path.exists('%s:' % d)] >>> drives Very clever! Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Re: Access to sysctl on FreeBSD?

2008-05-20 Thread Skye
Nevermind, I seem to have found it on my own =] http://python.org/doc/2.5/lib/module-struct.html This module performs conversions between Python values and C structs represented as Python strings. It uses format strings (explained below) as compact descriptions of the lay-out of the C structs and

Re: List of disk drives on Windows?

2008-05-20 Thread Mike Driscoll
On May 20, 2:45 pm, Tim Golden <[EMAIL PROTECTED]> wrote: > Bob Greschke wrote: > > This MUST have been asked before, but I can't seem to Google the right > > thing.  How can I get a list of drives on a Windows box, like ["C:\", > > "D:\"], like I can if I do something like listdir("/Volumes") on a

Re: Access to sysctl on FreeBSD?

2008-05-20 Thread Skye
Great, thanks for the help (I'm fairly new to Python, didn't know about ctypes) from ctypes import * libc = CDLL("libc.so.7") size = c_uint(0) libc.sysctlbyname("net.inet.ip.stats", None, byref(size), None, 0) buf = c_char_p(" " * size.value) libc.sysctlbyname("net.inet.ip.

Re: List of disk drives on Windows?

2008-05-20 Thread Mensanator
On May 20, 2:18 pm, Bob Greschke <[EMAIL PROTECTED]> wrote: > This MUST have been asked before, but I can't seem to Google the right > thing.  How can I get a list of drives on a Windows box, like ["C:\", > "D:\"], like I can if I do something like listdir("/Volumes") on a Mac? > > Thanks! > > Bob

subscribe

2008-05-20 Thread Deverter,Mark
-- http://mail.python.org/mailman/listinfo/python-list

Re: List of disk drives on Windows?

2008-05-20 Thread Tim Golden
Bob Greschke wrote: This MUST have been asked before, but I can't seem to Google the right thing. How can I get a list of drives on a Windows box, like ["C:\", "D:\"], like I can if I do something like listdir("/Volumes") on a Mac? A couple of options to get the ball rolling: 1) win32api.Get

Re: Using Python for programming algorithms

2008-05-20 Thread Roel Schroeven
Wow this resulted in far more reactions than I had expected ... [EMAIL PROTECTED] schreef: On 19 mai, 15:30, Roel Schroeven <[EMAIL PROTECTED]> wrote: Bruno Desthuilliers schreef: 1/ being interpreted or compiled (for whatever definition of these terms) is not a property of a language, but a

Re: What's wrong with that comment?

2008-05-20 Thread Joe P. Cool
Ludwig Miniatur wrote: > For example: > #!/usr/bin/env python > > from parser import suite, ast2list > fh = file(__file__) > s = fh.read() > fh.close() > ast = suite(s) > > while False: > print "hello world" > # comment > > Looks like a little bug in parser; but what I don't understand is that >

List of disk drives on Windows?

2008-05-20 Thread Bob Greschke
This MUST have been asked before, but I can't seem to Google the right thing.  How can I get a list of drives on a Windows box, like ["C:\", "D:\"], like I can if I do something like listdir("/Volumes") on a Mac? Thanks! Bob -- http://mail.python.org/mailman/listinfo/python-list

Re: Python in non-standard location erring with "No module named _sha256"

2008-05-20 Thread emallove
On May 20, 11:27 am, emallove <[EMAIL PROTECTED]> wrote: > I'm running into the below "No modules named _sha256" issue, with a > python installed in a non-standard location. > > $ python > Python 2.5.2 (r252:60911, May 20 2008, 09:46:50) > [GCC 3.3.3 (SuSE Linux)] on linux2 > Type "help", "copyrigh

Re: iterate start at second row in file not first

2008-05-20 Thread Mark d.
How about: mov = open(afile) line = mov.readline() ...(process your ':' line) for line in mov.readlines(): ... On May 20, 1:34 pm, [EMAIL PROTECTED] wrote: > i have a big file with sentences, the first file of each sentence > contains a colon(:) somewher eon that line > i want to jump past th

What's wrong with that comment?

2008-05-20 Thread Ludwig Miniatur
Hi, I ran into a funny thing when I played with the python parser, to build a python call graph for learning... When I have a (special) python program, that runs without any error it gives an error, when I try to parse it parser.suite. The error is, when my program has a comment on the last line a

Re: Access to sysctl on FreeBSD?

2008-05-20 Thread Martin v. Löwis
> How do I access the sysctl(3) call from Python on BSD? > > Specifically I want to retrieve: > > $ sysctl -d net.inet.ip.stats > net.inet.ip.stats: IP statistics (struct ipstat, netinet/ip_var.h) > > So I'll need some way of getting to struct ipstat from Python as well At the moment, only thro

Re: iterate start at second row in file not first

2008-05-20 Thread Falcolas
On May 20, 12:34 pm, [EMAIL PROTECTED] wrote: > how do i jump the first step there? i dont want to iterate the first > row...how do i start at the second? To simply bypass the first line, do a readline() on the file object before starting to process the file. To filter out particular lines throug

Re: iterate start at second row in file not first

2008-05-20 Thread jay graves
On May 20, 1:34 pm, [EMAIL PROTECTED] wrote: > i have a big file with sentences, the first file of each sentence > contains a colon(:) somewher eon that line > i want to jump past that sentence. > > if all(x != ':' for x in line): > > this way i can check but i dont want to check for every line in

Re: preserve history in the interactive python

2008-05-20 Thread Arnaud Delobelle
Nikhil <[EMAIL PROTECTED]> writes: > Nikhil wrote: >> Hi, >> >> I am using python -i, and I find it hard typing/pasting the commands >> from the previous interactive shell. Basically, is there anyway that >> I can preserve the history in the shell? >> I guess but not sure there should be something

Re: conventions/requirements for 'is' vs '==', 'not vs '!=', etc

2008-05-20 Thread Rhamphoryncus
On May 20, 12:09 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > Intern() is gone in 3.0 But not gone far: >>> import sys >>> sys.intern -- http://mail.python.org/mailman/listinfo/python-list

iterate start at second row in file not first

2008-05-20 Thread notnorwegian
i have a big file with sentences, the first file of each sentence contains a colon(:) somewher eon that line i want to jump past that sentence. if all(x != ':' for x in line): this way i can check but i dont want to check for every line in the whole file, quite unnecessary when i only need to ch

Re: default gettext localedir on windows

2008-05-20 Thread Thorsten Kampe
* ZeeGeek (Tue, 20 May 2008 09:31:27 -0700 (PDT)) > On May 17, 8:39 pm, Thorsten Kampe <[EMAIL PROTECTED]> wrote: > > * ZeeGeek (Sun, 4 May 2008 10:56:52 -0700 (PDT)) > > > On May 5, 1:16 am, Thorsten Kampe <[EMAIL PROTECTED]> wrote: > > > > * ZeeGeek (Sun, 4 May 2008 08:59:05 -0700 (PDT)) > > > >

Re: AttributeError: module object has no attribute

2008-05-20 Thread Nikhil
Marc 'BlackJack' Rintsch wrote: On Tue, 20 May 2008 23:31:15 +0530, Nikhil wrote: Peter Otten wrote: Nikhil wrote: I have recently written a small module. When I import the module, I always get the error only when I do >>> from local.my.module import * -- Traceback (most recent call las

Re: Write bits in file

2008-05-20 Thread [EMAIL PROTECTED]
On May 20, 12:14 am, Tim Roberts <[EMAIL PROTECTED]> wrote: > Monica Leko <[EMAIL PROTECTED]> wrote: > > >I have a specific format and I need binary representation. Does > >Python have some built-in function which will, for instance, represent > >number 15 in exactly 10 bits? > > For the record, I

Re: preserve history in the interactive python

2008-05-20 Thread Nikhil
Nikhil wrote: Hi, I am using python -i, and I find it hard typing/pasting the commands from the previous interactive shell. Basically, is there anyway that I can preserve the history in the shell? I guess but not sure there should be something like ~/.pyrc for configuring such but can someone

Re: preserve history in the interactive python

2008-05-20 Thread Nikhil
Nikhil wrote: Hi, I am using python -i, and I find it hard typing/pasting the commands from the previous interactive shell. Basically, is there anyway that I can preserve the history in the shell? I guess but not sure there should be something like ~/.pyrc for configuring such but can someone

Re: Write bits in file

2008-05-20 Thread castironpi
On May 20, 10:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > Monica Leko <[EMAIL PROTECTED]> wrote: > >  On May 18, 2:20?pm, Ken Starks <[EMAIL PROTECTED]> wrote: > > > You want your file considered as a sequence of bits rather > > > than a sequence of 8-bit bytes, do you? > > >  Yes. > > > >

Re: AttributeError: module object has no attribute

2008-05-20 Thread Marc 'BlackJack' Rintsch
On Tue, 20 May 2008 23:31:15 +0530, Nikhil wrote: > Peter Otten wrote: >> Nikhil wrote: >> >>> I have recently written a small module. When I import the module, I >>> always get the error >>> >>> >>> only when I do >>> >>> >>> from local.my.module import * >>> >>> -- >>> Traceback (most recent c

preserve history in the interactive python

2008-05-20 Thread Nikhil
Hi, I am using python -i, and I find it hard typing/pasting the commands from the previous interactive shell. Basically, is there anyway that I can preserve the history in the shell? I guess but not sure there should be something like ~/.pyrc for configuring such but can someone please let me

Re: Accumulating values in dictionary

2008-05-20 Thread Thomas Bellman
Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > from collections import defaultdict > d = defaultdict(int) # That means the default value will be 0 > for person in people: > d[person.fav_food] += 1 Ah! I didn't think of using int as the factory function. If you use this, then I believe the wa

Re: "indexed properties"...

2008-05-20 Thread castironpi
On May 20, 10:40 am, "David C. Ullrich" <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > > > > > >  pataphor <[EMAIL PROTECTED]> wrote: > > On Tue, 20 May 2008 06:12:01 -0500 > > David C. Ullrich <[EMAIL PROTECTED]> wrote: > > > > Well, ok. Like I said, I never _took_ the position tha

Re: conventions/requirements for 'is' vs '==', 'not vs '!=', etc

2008-05-20 Thread Terry Reedy
"Duncan Booth" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | In short, two equal strings may or may not be identical and any code which | makes assumptions based on observed behaviour is broken. If you want to be | able to test identity on strings safely then use the 'intern()'

Re: Misuse of list comprehensions?

2008-05-20 Thread s0suk3
On May 20, 12:22 pm, "John Salerno" <[EMAIL PROTECTED]> wrote: > "Paul McGuire" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > On May 20, 10:50 am, [EMAIL PROTECTED] wrote: > > > def compress(s): > > return list(set(s)) > > > That does the trick. > > Wow, I just *knew* there had

Re: AttributeError: module object has no attribute

2008-05-20 Thread Nikhil
Peter Otten wrote: Nikhil wrote: I have recently written a small module. When I import the module, I always get the error only when I do >>> from local.my.module import * -- Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute '/xyz/py

  1   2   3   >