473,554 Members | 3,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python Forum

Python programming language - Ask questions about python interpreter, control flow, data structures, modules errors, classes, standard library, gui, databases, unit testing, object oriented, structured programming and more.
35
2,940
thread by: Moosebumps | last post Jul 18 '05 by: David Eppstein
Does anyone here find the list comprehension syntax awkward? I like it because it is an expression rather than a series of statements, but it is a little harder to maintain it seems. e.g. you could do: result = for element in list: if element == 'blah':
35
2,304
thread by: Gabriel Zachmann | last post Jul 18 '05 by: Jorgen Grahn
Is there any generic way to use C++ libraries from within Python. I seem to recall that there are tools to generate wrappers for C-libraries semi-automatically. But those were still way too cumbersome, IMHO. What I would like to have is some module (or whatever), with which I can say "load this C++ library", and then, "create that C++...
35
2,020
thread by: Will Stuyvesant | last post Jul 18 '05 by: Steven Bethard
Here is a question about list comprehensions . The question is dumb because I can do without ; but I am posing the question because I am curious. This: >>> data = ,,] >>> result = >>> for d in data: .... for w in d:
35
2,919
thread by: les_ander | last post Jul 18 '05 by: Steve Holden
Hi, I know that i can do readline() from a file object. However, how can I read till a specific seperator? for exmple, if my files are name profession id #
35
3,350
thread by: Steven Bethard | last post Jul 18 '05 by: Steven Bethard
I have lists containing values that are all either True, False or None, e.g.: etc. For a given list: * If all values are None, the function should return None.
35
3,046
thread by: Michael Kearns | last post Jul 19 '05 by: ucntcme
I've been using python to write a simple 'launcher' for one of our Java applications for quite a while now. I recently updated it to use python 2.4, and all seemed well. Today, one of my colleagues noted that on her machine the launcher would complain it was missing a DLL - msvcr71.dll However, there's a very grey area concerning the...
35
2,406
thread by: bonono | last post Nov 22 '05 by: Bengt Richter
Hi, I am wondering if there is such a thing, as python is moving away from FP functions like dropwhile/takewhile etc.
35
5,475
thread by: Alex Martelli | last post Dec 2 '05 by: MrJean1
Having fixed a memory leak (not the leak of a Python reference, some other stuff I wasn't properly freeing in certain cases) in a C-coded extension I maintain, I need a way to test that the leak is indeed fixed. Being in a hurry, I originally used a q&d hack...: if sys.platform in ('linux2', 'darwin'): def _memsize(): """ this function...
35
75,134
thread by: pinkfloydhomer | last post Dec 24 '05 by: Alex Martelli
How do I check if a string contains (can be converted to) an int? I want to do one thing if I am parsing and integer, and another if not. /David
35
2,841
thread by: Michel Sanner | last post Jan 4 '06 by: Mike Meyer
Hello, One of the greatest feature of Python in my opinion is the way the interpreter can be used to integrate a wide variety of software packages by dynamically linking them. This approach has been extremely successful for us so far but now I run into a license nightmare. Some the libraries we wrapped using SWIG are under GPL but the...
35
25,073
thread by: rbt | last post Jan 29 '06 by: Thomas Bellman
I've been doing some file system benchmarking. In the process, I need to create a large file to copy around to various drives. I'm creating the file like this: fd = file('large_file.bin', 'wb') for x in xrange(409600000): fd.write('0') fd.close() This takes a few minutes to do. How can I speed up the process?
35
2,346
thread by: John Coleman | last post Feb 28 '06 by: Mc Osten
Greetings, I have a rough classification of languages into 2 classes: Zen languages and tool languages. A tool language is a language that is, well, a *tool* for programming a computer. C is the prototypical tool language. Most languages in the Algol family are tool languages. Visual Basic and Java are also tool languages. On the other hand,...
35
2,420
thread by: nagy | last post Jul 20 '06 by: Terry Reedy
I do the following. First create lists x,y,z. Then add an element to x using the augumented assignment operator. This causes all the other lists to be changed also. But if I use the assignment x=x+ instead of using the augumented assignment, the y and z lists do not change. Why is that? This does not happen when I work with integer data type...
35
3,994
thread by: Carl J. Van Arsdall | last post Jul 28 '06 by: sjdevnull
Alright, based a on discussion on this mailing list, I've started to wonder, why use threads vs processes. So, If I have a system that has a large area of shared memory, which would be better? I've been leaning towards threads, I'm going to say why. Processes seem fairly expensive from my research so far. Each fork copies the entire...
35
29,198
thread by: erikwickstrom | last post Oct 11 '06 by: MonkeeSage
Hi all, I'm sorry about the newbie question, but I've been searching all afternoon and can't find the answer! I'm trying to get this bit of code to work without triggering the IndexError. import shutil, os, sys
35
2,679
thread by: Ben | last post Jan 26 '07 by: Steve Holden
Hi, I have a python script on a unix system that runs fine. I have a python script on a windows system that runs fine. Both use tabs to indent sections of the code. I now want to run them on the same system, actually in the same script by combining bits and pieces. But whatever I try my windows tabs get converted to spaces when I transfer...
35
1,991
thread by: Arnaud Delobelle | last post Mar 9 '07 by: Gabriel Genellina
Hi all, Imagine I have three functions a(x), b(x), c(x) that each return something or raise an exception. Imagine I want to define a function that returns a(x) if possible, otherwise b(x), otherwise c(x), otherwise raise CantDoIt. Here are three ways I can think of doing it: ----------
35
4,882
thread by: Abandoned | last post Oct 19 '07 by: Hrvoje Niksic
I want to convert a string to command.. For example i have a string: a="" I want to do this list.. How can i do ?
35
2,181
thread by: bukzor | last post Jan 2 '08 by: Ali
I've found some bizzare behavior when using mutable values (lists, dicts, etc) as the default argument of a function. I want to get the community's feedback on this. It's easiest to explain with code. This example is trivial and has design issues, but it demonstrates a problem I've seen in production systems: def main(argv = ): 'print...
35
21,511
thread by: erik gartz | last post Jan 11 '08 by: Tim Chase
Hi. I'd like to be able to write a loop such as: for i in range(10): pass but without the i variable. The reason for this is I'm using pylint and it complains about the unused variable i. I can achieve the above with more lines of code like: i = 0 while (i != 10): i += 1 Is there a concise way to accomplish this without adding extra lines
35
2,191
thread by: globalrev | last post Oct 6 '08 by: Tobiah
http://reddit.com/r/programming/info/18td4/comments claims people take a lot of time to write a simple program like this: "Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five...
35
3,476
thread by: eliben | last post Aug 22 '08 by: Gabriel Genellina
Python provides a quite good and feature-complete exception handling mechanism for its programmers. This is good. But exceptions, like any complex construct, are difficult to use correctly, especially as programs get large. Most of the issues of exceptions are not specific to Python, but I sometimes feel that Python makes them more acute...
35
1,936
thread by: Stef Mientki | last post Oct 24 '08 by: Paul McNett
hello, I (again) wonder what's the perfect way to store, OS-independent, filepaths ? I can think of something like: - use a relative path if drive is identical to the application (I'm still a Windows guy) - use some kind of OS-dependent translation table if on another drive - use ? if on a network drive
35
1,921
thread by: Rick Giuly | last post Nov 21 '08 by: Aaron Brady
Hello All, Why is python designed so that b and c (according to code below) actually share the same list object? It seems more natural to me that each object would be created with a new list object in the points variable. class Blob: def __init__(self, points=): self._points = points
36
8,363
thread by: Dag | last post Jul 18 '05 by: Anton Vredegoor
Is there a python module that includes functions for working with prime numbers? I mainly need A function that returns the Nth prime number and that returns how many prime numbers are less than N, but a prime number tester would also be nice. I'm dealing with numbers in the 10^6-10^8 range so it would have to fairly efficient Dag

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.