473,543 Members | 2,383 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.
32
2,747
thread by: Robin Becker | last post Jan 13 '06 by: Bengt Richter
Is there some smart/fast way to flatten a level one list using the latest iterator/generator idioms. The problem arises in coneverting lists of (x,y) coordinates into a single list of coordinates eg f() --> or g(,) -->
32
4,363
thread by: Rene Pijlman | last post Mar 5 '06 by: plahey
One of the things I dislike about Java is the need to declare exceptions as part of an interface or class definition. But perhaps Java got this right... I've writen an application that uses urllib2, urlparse, robotparser and some other modules in the battery pack. One day my app failed with an urllib2.HTTPError. So I catch that. But then I...
32
1,824
thread by: John Salerno | last post Apr 8 '06 by: R. Bernstein
My first project when I started learning C# was to make a little timer to tell me when my laundry was done :) and I thought it would be fun to convert this to Python. Here's what I came up with after much struggling with the Timer class from the threading module -- as you can see, I abandoned it for the sleep() function from timer. Please...
32
5,612
thread by: David Isaac | last post Sep 15 '06 by: Blair P. Houghton
I have no experience with database applications. This database will likely hold only a few hundred items, including both textfiles and binary files. I would like a pure Python solution to the extent reasonable. Suggestions? Thank you, Alan Isaac
32
14,621
thread by: Licheng Fang | last post Sep 16 '06 by: Tim Peters
Basically, the problem is this: 'do' Python's NFA regexp engine trys only the first option, and happily rests on that. There's another example: 'oneself' The Python regular expression engine doesn't exaust all the
32
7,436
thread by: Kevin Walzer | last post Oct 23 '06 by: Peter Decker
I'm a Tcl/Tk developer who has been working, slowly, at learning Python, in part because Python has better support for certain kinds of applications that I want to develop than Tcl/Tk does. Naturally, I thought that I would use Tkinter as the GUI for these programs. However, in doing research into GUI development techniques, sample code, and...
32
5,770
thread by: Matias Jansson | last post Dec 25 '06 by: Carl Banks
I come from a background of Java and C# where it is common practise to have one class per file in the file/project structure. As I have understood it, it is more common practice to have many classes in a Python module/file. What is the motivation behind it, would it be a bad idea to have a guideline in your project that promotes a one class...
32
2,800
thread by: siggi | last post Feb 15 '07 by: Steve Holden
@Ben Sizer Hi Ben, in January I received your message re Pygame and Python 2.5: As a Python (and programming ) newbie allow me a - certainly naive - question:
32
1,610
thread by: Steve Holden | last post Oct 2 '07 by: Alia Khouri
I wondered if a straw poll could get some idea of readers' thoughts about when they will be migrating to 3.0 on, so I used the new widget on Blogger to add a poll for that. I'd appreciate if if you would go to http://holdenweb.blogspot.com/ and register your vote on your intended migration timescale.
32
2,671
thread by: andresj | last post Oct 4 '07 by: Steven D'Aprano
I was doing some programming in Python, and the idea came to my mind: using fractions instead of floats when doing 2/5. The problem arises when you try to represent some number, like 0.4 in a float. It will tell you that it's equal to 0.40000000000000002. "This is easy to fix", you may say. "You just use the decimal.Decimal class!". Well,...
32
5,880
thread by: Bob Greschke | last post Jun 27 '08 by: George Sakkis
I'm reading 3-byte numbers from a file and they are signed (+8 to -8million). This seems to work, but I'm not sure it's right. # Convert the 3-characters into a number. Value1, Value2, Value3 = unpack(">BBB", Buffer) Value = (Value1*65536)+(Value2*256)+Value3 if Value >= 0x800000: Value -= 0x1000000 print Value
32
2,155
thread by: =?ISO-8859-1?Q?Szabolcs_Horv=E1t?= | last post Jun 27 '08 by: Duncan Booth
I did the following calculation: Generated a list of a million random numbers between 0 and 1, constructed a new list by subtracting the mean value from each number, and then calculated the mean again. The result should be 0, but of course it will differ from 0 slightly because of rounding errors. However, I noticed that the simple...
32
3,765
thread by: Pedro Borges | last post Oct 30 '08 by: Steve Holden
Hi guys, Is there a way to improve the interpreter startup speed? In my machine (cold startup) python takes 0.330 ms and ruby takes 0.047 ms, after cold boot python takes 0.019 ms and ruby 0.005 ms to start.
32
1,501
thread by: Paulo J. Matos | last post Nov 4 '08 by: George Sakkis
Hi all, I am a Python beginner, reading through 2.6 tutorial. I am wondering where are structures? On the other hand, I think I might have the answer. Since Python focus on having one way to do it and structures are something like classes with only public methods, if I want structures that's what I should use. Is that right?
33
3,940
thread by: Joe Cheng | last post Jul 18 '05 by: Tim Ottinger
I'm curious about something... many Artima.com members who have a Java background and learned Python have come to the conclusion that Java and Python are highly complimentary languages. They would never consider filling the place Java has in their toolbox with Python, but recognize there are many tasks where it really pays to add Python to...
33
3,805
thread by: Diez B. Roggisch | last post Jul 18 '05 by: Michele Simionato
Hi, today I rummaged through the language spec to see whats in the for ... else: for me. I was sort of disappointed to learn that the else clauses simply gets executed after the loop-body - regardless of the loop beeing entered or not. So where is an actual use case for that feature? I imagined that the else-clause would only be...
33
3,515
thread by: Arthur | last post Jul 18 '05 by: David MacQuigg
>>>a= >>> for p in a: print p 1 2 3 >>> p 3 My naive expectation was that p would be 'not defined' from outside
33
1,745
thread by: Axel Boldt | last post Jul 18 '05 by: Asun Friere
Hello, is there a rationale for the following behavior: >>> a = (1,2) >>> b = (1,2) >>> a is b False >>> a = "12" >>> b = "12"
33
2,926
thread by: Darren Dale | last post Jul 18 '05 by: David Fraser
I love the language. I love the community. My only complaint is that Python for Windows is built with Visual Studio. It is too difficult to build python, or a module, from source. This is what open source is all about, isnt it? I even have a copy of visual studio, and I still cant build modules from source, because my academic copy is...
33
3,448
thread by: Nick Evans | last post Jul 18 '05 by: Carlos Ribeiro
Hello there, I have been on and off learning to code (with python being the second language I have worked on after a bit of BASIC). What I really want to know is, if you are going to actually write a program or a project of some sort, how do you actually start. Picture this, you know what you want the program to do (its features), you have...
33
2,961
thread by: Steven Bethard | last post Jul 18 '05 by: David Bolen
I feel like this has probably been answered before, but I couldn't find something quite like it in the archives. Feel free to point me somewhere if you know where this has already been answered. I have a list in a particular order that I want to split into two lists: the list of every nth item, and the list of remaining items. It's...
33
2,494
thread by: Jacek Generowicz | last post Jul 18 '05 by: David Mertz, Ph.D.
I would like to write a metaclass which would allow me to overload names in the definition of its instances, like this class Foo(object): __metaclass__ = OverloadingClass att = 1 att = 3
33
9,120
thread by: Jim Hill | last post Jul 18 '05 by: Jim Hill
I've done some Googling around on this and it seems like creating a here document is a bit tricky with Python. Trivial via triple-quoted strings if there's no need for variable interpolation but requiring a long, long formatted arglist via (%s,%s,%s,ad infinitum) if there is. So my question is: Is there a way to produce a very long...
33
1,873
thread by: Xah Lee | last post Jul 18 '05 by: A.M. Kuchling
i've started to read python tutorial recently. http://python.org/doc/2.3.4/tut/tut.html Here are some quick critique: quick example: If the input string is too long, they don't truncate it, but return it unchanged; this will mess up your column lay-out but that's usually better than the alternative, which would be lying about a value....
33
2,695
thread by: Quest Master | last post Jul 18 '05 by: Cameron Laird
I am interested in developing an application where the user has an ample amount of power to customize the application to their needs, and I feel this would best be accomplished if a scripting language was available. However, I want to code this application in Python, and I have not yet heard of an implementation of another scripting language...

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.