1,175 Posted Topics

Member Avatar for yemu
Member Avatar for gotm

With huge indentations like you have in your code my editor will go up in smoke! I will let someone else try it first! :)

Member Avatar for gotm
0
143
Member Avatar for sneekula

In the US unemployment numbers are blatantly underestimated. The governmant just released a sugarcoated number (U-3) of 8.5%, being months behind, leaving out many folks. A more honest number (U-6) at least considers the folks who have been unemployed long enough to drop out of official unemployment support, this number …

Member Avatar for GrimJack
0
478
Member Avatar for jmil2

It looks like you only want a 2D matrix, since you are talking about rows and columns. First of all, do not use list as a variable name since list is a builtin function in Python. Lists have a function append(), so use it. Commonly a basic matrix is populated …

Member Avatar for adam1122
0
8K
Member Avatar for henryxxll

In Python versions before Python3 if you use '/' for division and divide two integers, the result will always be an integer.

Member Avatar for woooee
0
134
Member Avatar for TimothyKhoo
Member Avatar for TimothyKhoo
0
75
Member Avatar for xgmx

An intelligent insect species could take over. Survivors of a galactic gamma ray burst.

Member Avatar for sneekula
0
162
Member Avatar for AlPhA

If you just want to stick part B to a widget on an assembly line, I agree that you could do that for the rest of your life without much education. The problem is that sooner or later all the simple stuff will be automated. Your simple job is gone …

Member Avatar for schoolsux
1
1K
Member Avatar for ithelp

Judging from the filth that food processing plants get by with, I don't think the FDA would be much of a threat! Being covered with raw hamburger could be considered a benefit.

Member Avatar for debasisdas
1
151
Member Avatar for Dave Sinkula

To be a Conservative you have to have something to conserve. I assume it's some kind of hoard stashed away someplace. If you have nothing, you might just be a Liberal.

Member Avatar for jephthah
0
666
Member Avatar for jephthah

Hehehe! It's time to mint $100 coins so we can get cars, boats and , yes, goats from the vending machine.

Member Avatar for MosaicFuneral
0
201
Member Avatar for SpectateSwamp

Years ago I met a guy in downtown Minneapolis snapping his fingers to chase away flying elephants. His answer: "Do you see any? See it works!"

Member Avatar for jephthah
0
160
Member Avatar for thehivetyrant

Here % is the modulo operator. It gives you the remainder of a division. [code=python]print(3 % 3) # 0 --> 3 is completely divisable by 3 print(6 % 3) # 0 --> 6 is completely divisable by 3 print(5 % 3) # 2 --> division leaves a ramainder of 2 …

Member Avatar for thehivetyrant
0
3K
Member Avatar for GrimJack

So, gravity is a monopole? Time could be a monopole unless it's circular. Do we have any tripoles?

Member Avatar for ahihihi...
0
202
Member Avatar for Ancient Dragon

If you watched the response given by the Governor of Louisiana a few days ago, you wonder if there is evolution.

Member Avatar for GrimJack
0
1K
Member Avatar for leegeorg07

Yes it's possible, you may have to consult the Python manual to understand it all: [code=python]# index the lines that contain given search words data = """\ this test finds how many times certain words like text appear in the data remember this is just a test """ filename = …

Member Avatar for woooee
0
115
Member Avatar for mangotango

Sometime it pays to write a short test code: [code=python]# set up a short test with Tkinter's # Label, Entry, Button and Text widgets # check some of the interactions from Tkinter import * def update(): data = entry.get() # clear any old text text.delete(1.0, END) text.insert(INSERT, data) # clear …

Member Avatar for sneekula
0
857
Member Avatar for snowfish

The simplest way would be to use Python's rot13 encoding to encode your password and then use the encoded password in your program. First use this code to create the encoded password: [code=python]# example of simple encoding/decoding using Python's 'rot13' # alphabet is shifted by 13 positions to nopqrstuvwxyzabcdefghijklm # …

Member Avatar for lllllIllIlllI
0
10K
Member Avatar for vidaj

Somebody mention this in another thread. You can convert BeautifulSoup.py from Python25 to Python30 with 2to3.py and it will work with Python30. You can use this little utility program: [code=python] # convert a Python25 code file to a Python30 code file # generates a backup file and overwrites the original …

Member Avatar for vidaj
0
1K
Member Avatar for pythonator
Member Avatar for originalremix

[QUOTE=leegeorg07;839141]yes it is if you use the string function (below) e.g. [code=python] b = "d" b.isupper() # will return false b.islower() # will return true [/code] this is something i came up with in 5 mins that does it quicker and is easier to read: [code=python] def checker(): b = …

Member Avatar for woooee
0
172
Member Avatar for ning2009

Here would be one way to do this: [code=python]text = """\ 159 J=1661,3169,1679,3181 SEC=SLAB2 66 J=5597,5596,7523,7522 SEC=WALL1""" print(text) print('-'*35) # create a list of words excluding item containing 'SEC=" temp_list = [item for line in text.split('\n') for item in line.split() if not 'SEC=' in item] #print temp_list # test # …

Member Avatar for ning2009
0
111
Member Avatar for tillaart36

One of the ways to do this is to flatten the nested list. Here is an example: [code=python]# flatten a nested list def flatten(q): """ a recursive function that flattens a nested list q """ flat_q = [] for x in q: # may have nested tuples or lists if …

Member Avatar for tillaart36
0
247
Member Avatar for eowyn0622

If you get a notebook, don't get an HP, it has a lousy keyboard, get a Toshiba, Sony or Acer. Also, looks like the little Acer notbook comes with Widows XP rather than the frustrating Vista.

Member Avatar for MosaicFuneral
0
170
Member Avatar for Skimy

Strangely enough Python always had the '/' and '//' operators, but it took Python30 to assign them appropriately. So now '/' is floating point and is '//' integer, before they were both integer division operators.

Member Avatar for chaney44145
0
116
Member Avatar for GrimJack

Thank God I don't live in St. Paul, or I would only have one US Senator.

Member Avatar for sneekula
0
141
Member Avatar for srk619

You can play with this: [code=python]# draw a dragon curve fractal using Tinter's turtle # dense version using recursion # modified from: http://www.rosettacode.org/wiki/Dragon_curve from turtle import * def dragon(step, length, zig=right, zag=left): if step <= 0: forward(length) return step -= 1 length /= 1.41421 zig(45) dragon(step, length, right, left) zag(90) …

Member Avatar for srk619
0
98
Member Avatar for pythonnewbie1

Please use code tags with your code to preserve the indentations. Otherwise the code is very difficult to read and not too many folks will help. [noparse][code=python][/noparse] your Python code here [noparse][/code][/noparse]

Member Avatar for jlm699
0
227
Member Avatar for James1997123

Wow! The address bar of your browser window can be used to run javascript. What is the javascript to wipe out the hard disk? :)

Member Avatar for chriswellings
0
606
Member Avatar for kiddo39

First let's create a sample image file: [code=python]# drawing with PIL (Python Image Library) # draw and save a small French flag (blue, white, red) from PIL import Image, ImageDraw # create a new 24x16 pixel image surface (default is black bg) img = Image.new("RGB", (24, 16)) # set up …

Member Avatar for lllllIllIlllI
0
147
Member Avatar for tillaart36

BTW, avoid using tabs for your indentations. Using 4 spaces makes your code more readable and avoids problems with other folks' editors

Member Avatar for tillaart36
0
2K
Member Avatar for dilipkk

Here is a Python module that is used for data mining: [url]http://www.ailab.si/orange[/url]

Member Avatar for dilipkk
0
107
Member Avatar for harrykokil

In Tkinter terminology this widget is called a Scale. Check the manual for details.

Member Avatar for woooee
0
76
Member Avatar for tomtetlaw

I heard that the PyOpenGL project is pretty much dead. However, the good news is that wxPython has incorporated the Open Graphis Library (OGL). Here is an example: [code=python]# the Open Graphics Library (OGL) is now pretty well # integrated with wxPython import wx import wx.lib.ogl as ogl class MyFrame(wx.Frame): …

Member Avatar for lllllIllIlllI
0
104
Member Avatar for Florest

This short example may help you: [code=python]# experimenting with Python's csv module # used to process Comma Separated Values # the type of files generated by most common spreadsheet programs # read as a dictionaries and remove one of the keys import csv # the csv test data # here …

Member Avatar for sneekula
0
3K
Member Avatar for harrykokil

According to the latest Tkinter manual that you can get from: [url]http://infohost.nmt.edu/tcc/help/pubs/tkinter/tkinter.pdf[/url] it is myscale.set(value) to get a value use: value = myscale.get()

Member Avatar for sneekula
0
64
Member Avatar for Dave Sinkula

God will punish smokers not for what they are doing to themselves, but for what they are doing to others.

Member Avatar for jbennet
0
4K
Member Avatar for NicAx64
Member Avatar for loren41

[QUOTE=loren41;832005]Thanks Gribouillis. Now I have to figure out how to test for an uppercase letter. I won't always know it will be a "B." As always, the solution seems simple after you see it![/QUOTE] You can use one of Python's string functions: [code=python]c = 'T' print(c.isupper()) # --> True [/code]

Member Avatar for sneekula
0
258
Member Avatar for daniwebnewbie

A dictionary has hashed lookup and is highly optimized in Python, since the language uses dictionaries internally too. I would go with one dictionary. C++ has the STL map<const Key, Data> container, but I don't know if that would be any memory saving, and don't think the lookup is hashed …

Member Avatar for paddy3118
0
261
Member Avatar for NicAx64

As good paying jobs disappear in the USA, so will US customers of these now imported products. I also think that a free society produces better ideas than a 'slave' society.

Member Avatar for GrimJack
0
195
Member Avatar for FengG

The best way for your level would be to build up a string in the loop: [code=python]alph = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',\ 'q','r','s','t','u','v','w','x','y','z'] num =[2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9] # testing only phone = "555-GET-FOOD".lower() #phone = raw_input('enter phone number in the format xxx-xxx-xxxx ').lower() # build up from an empty string s = "" for index …

Member Avatar for FengG
0
6K
Member Avatar for dise652

Wow, finally someone managed to sell rabbit pellets as candy. I must go right out and get some of those Chocolate Shittles.

Member Avatar for sneekula
0
103
Member Avatar for Madbuda

[QUOTE=MosaicFuneral;793176]Hold all the other crap, just throw in it a pan till it's crispy! I'd be in heaven, till the eventual endless hours on the toilet from all that grease.[/QUOTE]Hopefully you can pour off some of the grease. I don't think it would be any worse than the average hamburger.

Member Avatar for jbennet
0
414
Member Avatar for devstudio.2007

What Operating System are you using? You can append to the pythonpath in each your programs.

Member Avatar for sneekula
0
105
Member Avatar for admiralxgmx

Sounds like a real adventure! Hope you don't fall into the rebels' hands or get arrested by the corrupt law enforcers. Don't drink the water!

Member Avatar for sneekula
0
510
Member Avatar for dise652
Member Avatar for karenmaye

Running PyGame from within wxPython will create a conflict, since each use their own event loops, and the event queue will now contain events that won't match.

Member Avatar for sneekula
0
2K
Member Avatar for JeyC

I assume you mean something simple like this: [code=python]# extract the numeric value before the word 'DIFFERENCES' text = """\ FILE A HAS 2266 LINES OF WHICH 951 WERE IGNORED FILE B HAS 2193 LINES OF WHICH 878 WERE IGNORED THERE WERE 2 DIFFERENCES""" word_list = text.split() print(word_list) for ix, …

Member Avatar for JeyC
0
122
Member Avatar for alicem

Try something along that line: [code=python]# can be used for Python25/26 def int2bin(num, bits): """ returns the binary of integer num, using bits number of digits, will pad with leading zeroes """ bs = '' for x in range(0, bits): if 2**x == 2**x & num: bs = '1' + …

Member Avatar for jlm699
0
6K

The End.