1,175 Posted Topics
Re: We need some actual examples of your lists and the sort order you want. | |
Re: With huge indentations like you have in your code my editor will go up in smoke! I will let someone else try it first! :) | |
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 … | |
Re: 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 … | |
Re: In Python versions before Python3 if you use '/' for division and divide two integers, the result will always be an integer. | |
Re: If they ask for money up front, then it is most likely a ripoff! | |
Re: An intelligent insect species could take over. Survivors of a galactic gamma ray burst. | |
Re: 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 … | |
Re: 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. | |
Re: 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. | |
Re: Hehehe! It's time to mint $100 coins so we can get cars, boats and , yes, goats from the vending machine. | |
Re: 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!" | |
Re: 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 … | |
Re: So, gravity is a monopole? Time could be a monopole unless it's circular. Do we have any tripoles? | |
Re: If you watched the response given by the Governor of Louisiana a few days ago, you wonder if there is evolution. | |
![]() | Re: 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 = … |
Re: 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 … | |
Re: 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 # … | |
Re: 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 … | |
Re: [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 = … | |
Re: 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 # … | |
Re: 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 … | |
Re: 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. | |
Re: 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. | |
Re: Thank God I don't live in St. Paul, or I would only have one US Senator. | |
Re: 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) … | |
Re: 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] | |
Re: Wow! The address bar of your browser window can be used to run javascript. What is the javascript to wipe out the hard disk? :) | |
Re: 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 … | |
Re: BTW, avoid using tabs for your indentations. Using 4 spaces makes your code more readable and avoids problems with other folks' editors | |
Re: Here is a Python module that is used for data mining: [url]http://www.ailab.si/orange[/url] | |
Re: In Tkinter terminology this widget is called a Scale. Check the manual for details. | |
Re: 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): … | |
Re: 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 … | |
Re: 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() | |
Re: God will punish smokers not for what they are doing to themselves, but for what they are doing to others. | |
Re: So, where is the user part? | |
Re: [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] | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: Wow, finally someone managed to sell rabbit pellets as candy. I must go right out and get some of those Chocolate Shittles. | |
Re: [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. | |
Re: What Operating System are you using? You can append to the pythonpath in each your programs. | |
Re: 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! | |
Re: I would be more concerned about Tyson Lawson's fingers. | |
Re: 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. | |
Re: 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, … | |
Re: 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' + … |
The End.