988 Posted Topics

Member Avatar for Flyin dagger

Well, it took George Bush eight years to make such an ungodly mess, so it will take Barack Obama and his team a little while to fix it. The first things you may see is that the torture of prisoners is gone, and the US will treat other countries like …

Member Avatar for Aia
0
783
Member Avatar for kes_ee

In Python it would look like: [code=python]fout = open("test1.txt", "w") fout.write("save something ...\n") fout.write("save something more ...\n") fout.close() # or C++ style (allowed in Python2) fout = open("test2.txt", "w") print >>fout, "save something ..." print >>fout, "save something more ..." fout.close() # more like PERL import sys old = sys.stdout …

Member Avatar for Ene Uran
0
138
Member Avatar for sadix
Member Avatar for MosaicFuneral

I wonder if they ever got all that salmonella contaminated peanut butter off the shelves?

Member Avatar for jephthah
0
392
Member Avatar for amrith92

I wouldn't walk through a cemetery in the middle of the night! Hollywood loves to scare people with ghost stories/movies.

Member Avatar for jephthah
1
347
Member Avatar for joshSCH

[QUOTE=jwenting;469208]Not all illegal aliens take to criminal enterprise beyond the federal crime of crossing the border illegally maybe, but it is a fact that those who do are often among the worst repeat offenders. And they often get very light sentences, being usually just kicked out of the country only …

Member Avatar for GrimJack
1
1K
Member Avatar for ndeniche

Brain: An enchanting brain has to be capable of a balanced mix of creativity, wit and understanding. My bosses brain contains the C++ manual in every detail, but otherwise he is rude and crude and devoid of any people skills. He has a very ugly wife and three very ugly …

Member Avatar for ditz
0
1K
Member Avatar for tomtetlaw

I you are on Windows and have several versions of Python installed, you can write a little batch file to make sure the IDLE of the correct version is runnig: [code]REM a batch file to force IDLE to use Pyhon30 REM saved as IDLE30.bat C:\Python30\pythonw.exe -u C:\Python30\Lib\idlelib\idle.pyw [/code]The poor quality …

Member Avatar for vegaseat
0
159
Member Avatar for hughesadam_87

Your problem is too simple to bother with regex: [code=python]mylist = ['adam', 'bill', 'jon/juan'] newlist = [item.replace('/', '') for item in mylist] print(mylist) # ['adam', 'bill', 'jon/juan'] print(newlist) # ['adam', 'bill', 'jonjuan'] [/code]

Member Avatar for hughesadam_87
0
130
Member Avatar for MONODA

Maybe something like this: [code=python]import random low = 1 high = 9 mylist = [(random.randint(low, high), ) for k in range(10)] print(mylist) """ a possible display of one element tuples --> [(9,), (5,), (6,), (2,), (8,), (3,), (4,), (2,), (6,), (1,)] """ [/code]

Member Avatar for MONODA
0
10K
Member Avatar for rasizzle

Not quite sure what you want, but maybe function zip() will help: [code=python]buy_list = [1,2,3,4,9,11,77,99] sell_list = [0,7,8,10,12,15] # removes the excess items of the longer list buy_sell = zip(buy_list, sell_list) print buy_sell for buy, sell in buy_sell: print buy, sell """ my display --> [(1, 0), (2, 7), (3, …

Member Avatar for shadwickman
0
316
Member Avatar for TerabyteST

Here is an example: [url]http://www.daniweb.com/forums/showpost.php?p=890166&postcount=111[/url]

Member Avatar for scru
0
120
Member Avatar for infinitelygreen

Python 2.5.4 is the version I have installed. Python 2.6 has all sorts of problems at least on Windows, since it is compiled with a different MS C compiler. A good number of modules are simply not available for Python 2.6. Python 2.6 is supposed to help you to transition …

Member Avatar for infinitelygreen
0
96
Member Avatar for GrimJack

Germany during WW2 send many of their most educated people to the frontline because the ultra rightwing government in charge in those days did not like well educated people.

Member Avatar for GrimJack
0
716
Member Avatar for jephthah

Imagine a planet where all the beings live by unbiased rules and pay their fair taxes.

Member Avatar for jephthah
1
149
Member Avatar for fkadri

In order to make buttons behave like standard buttons in your dialog box, you simply create an image button from a standard button and an image: [code=python]class BitmapDialog(wx.Dialog): def __init__(self, text): wx.Dialog.__init__(self, None, -1, title="BitmapDialog", size=(250,150)) bmp = wx.Bitmap('ok.png') w, h = bmp.GetSize() x = 35 y = 90 wx.StaticBitmap(self, …

Member Avatar for fkadri
0
244
Member Avatar for billymcguffin

Use this to clear the screen on a console program: [code=python]import sys # on Windows os.system("CLS") # on Linux os.system('clear') [/code] Also for my taste avoid using globals, they can get you into conflicts. You can generally pass them to and from functions in the arguments. Do you want to …

Member Avatar for billymcguffin
0
358
Member Avatar for Salem
Member Avatar for ithelp

[QUOTE=ithelp;870585]What are old C/C++ programmers supposed to do then ? :([/QUOTE]Get involved in politics, that takes little brain power.

Member Avatar for Ene Uran
0
188
Member Avatar for mindis

Just to add to shibby's very nice explanation: [code=python]# passing a class variable to other classes class C1(object): def __init__(self): print("in class C1") # self makes mc1 available to the class instance self.mc1 = 77 class C2(object): mc2 = 88 def __init__(self): print("in class C2") # create an instance of …

Member Avatar for Ene Uran
0
227
Member Avatar for Ancient Dragon

Thanks AD! My dad had an LP of Victor Borge with this sketch on it! Very amusing!

Member Avatar for Ene Uran
0
27
Member Avatar for tomtetlaw

The pygame.KEYDOWN event figures this one out, just put it into an if statement.

Member Avatar for tomtetlaw
0
454
Member Avatar for ithelp
Member Avatar for aot

Here is an example without a titlebar and showing fullscreen: [code=python]# wx.Frame with no title bar and showing fullscreen # modified from vegaseat's example import wx def exit(event): frame.Close(True) app = wx.App(0) # create a window, no-parent, -1 is default ID, style with no titlebar frame = wx.Frame(parent=None, id=-1, pos=(50,100), …

Member Avatar for aot
0
255
Member Avatar for ning2009

This line: if float(path_value[i]) == float(line1000[0]): will give you major headaches, since floats are usually off by very small values and are such not always equal. Use the function fuzzy_equals for that: [code=python]def fuzzy_equals(a, b, delta=0.000001): """ used for comparison of floating point numbers a and b """ return -delta …

Member Avatar for ning2009
0
218
Member Avatar for GrimJack

Who says you have to use aluminum to build windmills? The present NiH batteries on hybrid cars do not use cadmium. The safe life span of a nuclear power plant is 25 years and then you are stuck with a highly radioactive mess. If you use aluminum for your windmills, …

Member Avatar for GrimJack
0
88
Member Avatar for sneekula

Just heard in the financial news: The total of bad loans of the Royal Bank of Scotland is equal to the annual revenue of England. That's just one bank.

Member Avatar for vegaseat
0
255
Member Avatar for Dave Sinkula

Conservatives are me, me, me and don't give a hoot about their fellow human beings. Libertarians believe in full individual freedom of thought, expression, and action.

Member Avatar for jephthah
0
666
Member Avatar for s_jmp
Member Avatar for Dave Sinkula

I am a drinker and have spilled drinks on others. Will I be punished?

Member Avatar for jbennet
0
4K
Member Avatar for Comatose
Member Avatar for Ene Uran

I am looking for a good example of the tarfile module, writing to and reading from an archive. Particularly the highly compressed filename.tar.bz2 format.

Member Avatar for BearofNH
0
154
Member Avatar for ghostworkers
Member Avatar for vegaseat

Wonder if you can get past airport security with a suitcase full of antimatter?

Member Avatar for sneekula
0
148
Member Avatar for strobon
Member Avatar for 4pennies

Starting with and empty string, you have to build up your code string in the loop, and then write it to the file outside the loop: [code=python]def encode(): mess = raw_input ("Enter message:") joinnum = "" for i in mess: nummess = ord (i) * 2 * 7 + 3 …

Member Avatar for 4pennies
0
96
Member Avatar for breatheasier

Please do not mix tabs and spaces for indentations in your code. Makes a mess of your code when I copy it into my editor! Many editors have different spaces per tab settings. Use spaces only, preferably 4 spaces like most programmers use! Your problem is here: [code=python] for j …

Member Avatar for BearofNH
0
157
Member Avatar for karthik.c

Just an observation, I would avoid using variable names like l1, l2 and so on, they look a lot like numbers 11, 12. Here is an example how to use Python function map(): [code=python]q = [1, 2, 3, 4, 5] # map applies float() to every element in the list …

Member Avatar for scru
0
20K
Member Avatar for beanryu

My advice, don't use the Python Shell for programming, use an editor. The Python Shell interative interpreter is only for very short tests. It is basically there to confuse beginners and discourage them from using Python. :)

Member Avatar for breatheasier
0
2K
Member Avatar for sony_b

Do you have to maintain the position in the second file? What would a line of data in that file look like?

Member Avatar for woooee
0
144
Member Avatar for Ene Uran

For the second year running Python has been selected as the Language of the Year by Linux users: [code] Linux Users' Programming Languages of the Year 2008 PHP 115 13.36% Perl 72 8.36% Python 226 26.25% Ruby 46 5.34% C 114 13.24% C++ 129 14.98% Java 106 12.31% Lisp 9 …

Member Avatar for breatheasier
0
146
Member Avatar for mahela007

Expanding on jrcagle post: [code=python]import shutil source_file = r"C:\Python25\Atest\Bull\shutil_test.txt" destination = r"C:\Python25\Atest\Bull\Test" # this copies the source file to the destination directory # the destination directory has to exist # if the filename already exists there, it will be overwritten # access time and last modification time will be updated …

Member Avatar for Ene Uran
0
209
Member Avatar for karthik.c

Oh yes, Python has an array type, but you must import module array: [code=python]# module array has Python's array type import array # Python25 use 'c' as the character typecode # Python30 uses unicode character typecode 'u' char_array = array.array('c', 'hello world') print(char_array[0]) # h print(char_array) # array('c', 'hello world') …

Member Avatar for karthik.c
0
185
Member Avatar for juzzy

HTML code is easy to learn and you can format text using a simplified version of it, and show it in the wx.html.HtmlWindow() widget. Here is an example: [url]http://www.daniweb.com/forums/post803532-107.html[/url]

Member Avatar for juzzy
0
1K
Member Avatar for scru
Member Avatar for mahela007

[QUOTE=jrcagle;803601]Just to add to scru's point: Being able to re-use code is an extremely important but sometimes overlooked feature of programming. Its main value is not saving time, but eliminating bugs. That is, if the code for CD works provably correctly (or testably correct even), then a DVD class built …

Member Avatar for lllllIllIlllI
0
650
Member Avatar for mahela007

Welcome to this forum. Since just about everything in Python is an object, you are doing OOP already. Look at it this way, a class is just one more convenient tool to group things together. If the class concept bothers you, you can do major programming without it. After all, …

Member Avatar for jrcagle
0
80
Member Avatar for scru

> I know Python introspection feature are powerful, what I can't seem to figure out is how to get the name of the current class. > > Example: class Foo: def bar(self): print(classname) > Then my output should be `Foo`. Bonus points if I can get which module it resides …

Member Avatar for Ene Uran
0
135
Member Avatar for mahela007

Even the IDLE that comes with Python30 will insist to use PYthon25 if installed. There must be a file association config file somewhere that screws this up. I finally wrote a batch file (I use Windows Vista) and that solves the problem: [code]REM a batch file to force IDLE to …

Member Avatar for Ene Uran
0
68
Member Avatar for curiouskitten

There would be no changes using a list of vowels, the 'in' operator works the same way: [code=python]first = raw_input("Enter a sentence :\n") second = "" #vowels = 'aeiou' vowels = ['a','e','i','o','u'] for i in first: if i in vowels: second = second+i.upper() else : second = second+i print second …

Member Avatar for Ene Uran
0
11K

The End.