473,543 Members | 2,917 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.
25
2,722
thread by: PNY | last post Mar 30 '07 by: bvdet
Hi there, I am having some trouble with list manipulation and was hoping someone could help me. I have no problem reading in a text file as a list using filename.readlines(). However, I am having some trouble with searching through this list to display the elements that I want. I have a text file with this general format: ...
25
5,825
thread by: 7stud | last post Apr 15 '07 by: Diez B. Roggisch
I can't break out of the for loop in this example: ------ import sys lst = for line in sys.stdin: lst.append(line) break
25
2,548
thread by: samjnaa | last post Apr 17 '07 by: Alex Martelli
Please check for sanity and approve for posting at python-dev. In Visual Basic there is the keyword "with" which allows an object- name to be declared as governing the following statements. For example: with quitCommandButton .enabled = true .default = true end with
25
2,304
thread by: Eric | last post Apr 18 '07 by: Eric_Dexter
Hello, after reading some of the book Programming Python it seems that python is something I would like to delve deeper into. The only thing is, I have no idea what I should try and write. So I was hoping that someone here could help point me to a group/project that would be a good starting place for a person with limited python knowledge, but...
25
1,643
thread by: John Nagle | last post May 13 '07 by: Robert Brown
Some faster Python implementations are under development. JPython has been around for a while, and PyPy and ShedSkin continue to move forward. It's worth thinking about what slows down Python implementations. It isn't the dynamism, really. As others have pointed out in the Python literature, most of the time, the more elaborate dynamic...
25
4,658
thread by: Alex Popescu | last post Aug 2 '07 by: Alex Popescu
Hi all! I am pretty sure this has been asked a couple of times, but I don't seem to find it on the archives (Google seems to have a couple of problems lately). I am wondering what is the most pythonic way of dealing with missing keys and default values. According to my readings one can take the following approaches:
25
4,072
thread by: beginner | last post Jul 26 '07 by: Marc 'BlackJack' Rintsch
Hi, I am wondering how do I 'flatten' a list or a tuple? For example, I'd like to transform or ] to . Another question is how do I pass a tuple or list of all the aurgements of a function to the function. For example, I have all the arguments of a function in a tuple a=(1,2,3). Then I want to pass each item in the tuple to a function f...
25
2,617
thread by: tooru honda | last post Sep 10 '07 by: Lawrence D'Oliveiro
Hi, I have read the source code of the built-in random module, random.py. After also reading Wiki article on Knuth Shuffle algorithm, I wonder if the shuffle method implemented in random.py produces results with modulo bias. The reasoning is as follows: Because the method random() only produces finitely many possible results, we get...
25
3,757
thread by: jwrweatherley | last post Sep 19 '07 by: paulhankin
I'm pretty new to python, but am very happy with it. As well as using it at work I've been using it to solve various puzzles on the Project Euler site - http://projecteuler.net. So far it has not let me down, but it has proved surprisingly slow on one puzzle. The puzzle is: p is the perimeter of a right angle triangle with integral length...
25
3,000
thread by: Lennart Benschop | last post Oct 29 '07 by: Gabriel Genellina
Python has had the Decimal data type for some time now. The Decimal data type is ideal for financial calculations. Using this data type would be more intuitive to computer novices than float as its rounding behaviour matches more closely what humans expect. More to the point: 0.1 and 0.01 are exact in Decimal and not exact in float. ...
25
2,118
thread by: Brian | last post Dec 8 '07 by: Jacob Hallen
Had a unsettling conversation with a CS instructor that teaches at local high schools and the community college. This person is a long-term Linux/C/Python programmer, but he claims that the install, config, and library models for C# have proved to be less problematic than Python. So both his courses (intro, data structs, algorithms) are...
25
1,537
thread by: Licheng Fang | last post Dec 6 '07 by: samwyse
I mean, all the class instances that equal to each other should be reduced into only one instance, which means for instances of this class there's no difference between a is b and a==b. Thank you.
25
1,275
thread by: MartinRinehart | last post Jan 15 '08 by: Jan Claeys
I'm a Java guy who's been doing Python for a month now and I'm convinced that 1) a multi-paradigm language is inherently better than a mono-paradigm language 2) Python writes like a talented figure skater skates. Would you Python old-timers try to agree on a word or two that completes:
25
2,483
thread by: Erik Lind | last post Jan 17 '08 by: Lie
I'm new to Python, and OOP. I've read most of Mark Lutz's book and more online and can write simple modules, but I still don't get when __init__ needs to be used as opposed to creating a class instance by assignment. For some strange reason the literature seems to take this for granted. I'd appreciate any pointers or links that can help...
25
2,565
thread by: patrol | last post Jul 18 '08 by: patrol
I want to prevent some process from running. The code is in the following. I encounter some unexpected troubles. Probelm1: This program cannot terminate "scrcons.exe" and "FNPLicensingService.exe",which are system processes. Problem2:After a while, this program will abort by error File "C:\Python25\lib\wmi.py", line 397, in __call__...
25
2,749
thread by: Jeremy Banks | last post Sep 4 '08 by: Gabriel Genellina
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the object itself is a subprocess, not a "popen". It seems that it would be more accurate to just name the class Subprocess, can anyone explain why this...
25
1,428
thread by: Dmitry S. Makovey | last post Sep 28 '08 by: Dmitry S. Makovey
Hi, after hearing a lot about decorators and never actually using one I have decided to give it a try. My particular usecase is that I have class that acts as a proxy to other classes (i.e. passes messages along to those classes) however hand-coding this type of class is rather tedious, so I decided to use decorator for that. Can somebody...
25
1,838
thread by: tmallen | last post Nov 5 '08 by: Miles
I'm parsing some text files, and I want to strip blank lines in the process. Is there a simpler way to do this than what I have here? lines = filter(lambda line: len(line.strip()) 0, lines) Thomas
25
1,628
thread by: dpapathanasiou | last post Nov 19 '08 by: Arnaud Delobelle
I have some old Common Lisp functions I'd like to rewrite in Python (I'm still new to Python), and one thing I miss is not having to declare local variables. For example, I have this Lisp function: (defun random-char () "Generate a random char from one of " (if (< 50 (random 100)) (code-char (+ (random 10) 48)) ; ascii 48 = 0
24
1,771
thread by: Stephen Horne | last post Jul 18 '05 by: Stephen Horne
PEP315 (Enhanced while loop) suggests a syntax as follows... do: ... while condition: ... The motives are IMO good, but I don't like this solution. It replicates a problem with the C do loop (even though this is actually different to the C do loop).
24
3,496
thread by: Batista, Facundo | last post Jul 18 '05 by: Jegenye 2001 Bt
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing the code. Thank you. .. Facundo
24
12,989
thread by: Runic911 | last post Jul 18 '05 by: Andrew Dalke
Does anyone know how i can fix my Palindrome program? s = raw_input('Enter a String: ') punctuation = '%$!*.,-:? ;()\'\"\\' i = 0 h = 0 t = 0 p = '' z = 0 while s!= ' ':
24
6,713
thread by: Hung Jung Lu | last post Jul 18 '05 by: Bengt Richter
Hi, Does anybody know where this term comes from? "First-class object" means "something passable as an argument in a function call", but I fail to see the connection with "object class" or with "first-class airplane ticket". I just find the name a bit strange. Also, if there are first-class objects, what would the second-class objects or...
24
1,910
thread by: Uwe Mayer | last post Jul 18 '05 by: Josiah Carlson
Hi, I have the following inter-class relationships: __main__: (in file LMCMain.py) imports module FileIO defines class LMCMain instanciats main = LMCMain(...) FileIO.py:
24
2,672
thread by: Andrew Koenig | last post Jul 18 '05 by: Peter Maas
PEP 315 suggests that a statement such as do: x = foo() while x != 0: bar(x) be equivalent to while True:

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.