4,305 Posted Topics

Member Avatar for eleonora

Well, it is our policy on the forum not to do homework for you, but here are some elaborations (tests) that should help you in a hintful way ... [code=python]# months abbreviated dictionary (created from a list) mad = {'MAR': 3, 'FEB': 2, 'AUG': 8, 'SEP': 9, 'APR': 4, 'JUN': …

Member Avatar for eleonora
0
209
Member Avatar for twomers

I just read an article in the Guardian about large scale windfarming off the Scottish coast. That must be a perennially windy corner. They are using knowledge gained with oil rigs there, and are using super large blades. Why they are rusty I don't know, but then way out there, …

Member Avatar for bumsfeld
0
737
Member Avatar for Noliving

It almost looks like graphics22 is a variant of the graphics module written by John Zelle for use with the book "Python Programming: An Introduction to Computer Science" (Franklin, Beedle & Associates). This is a custom wrapper for Tkinter. Unless you have a detailed manual for it, help from us …

Member Avatar for vegaseat
0
120
Member Avatar for nish88
Member Avatar for jliu66

What does a typical element in your list look like? If it's a file, what does a typical data line look like?

Member Avatar for woooee
0
167
Member Avatar for Dave Sinkula

9/11 was a conspiracy alright, a conspiracy by Mister Laden and friends. He and most of his friends are still on the loose, thanks to the fact that our boys are too busy pilfering Iraq right now. With boys I don't mean our troops, but their leaders.

Member Avatar for jwenting
0
517
Member Avatar for aot

That may be tough because a continuous key press is interpreted by your operating system as a repeated key press.

Member Avatar for Quarks
0
15K
Member Avatar for LanierWexford

Actually the whole exercise is a great example of Python's slicing operator ... [code=python]# slicing operator seq[begin : end(exclusive) : step] # step is optional # defaults are index begin=0, index end=len(seq), step=1 """ separate info in line into ID#,Last,First,Territory#,Office#,Salary,SSN,Department#,JobClass 00001,ADAMSON,JAMES,01,01,40000.00,145503242,01,02 """ line = "00001JAMES ADAMSON 010104000014550324201021500067500040010011593" # extract the …

Member Avatar for vegaseat
0
207
Member Avatar for kuoz

For plotting you can also install VPython, see ... [url]http://www.daniweb.com/code/snippet376.html[/url] or wxPython, take a look at ... [url]http://www.daniweb.com/code/snippet689.html[/url]

Member Avatar for vegaseat
0
83
Member Avatar for CoolFool

Look at your conditions: 90 - 100: A 80 - 89: B 70 - 79: C 60 - 69: D < 60: F The last line says, if the score is less than 60, then the grade is an F. That would be the easiest to write for the computer …

Member Avatar for woooee
0
166
Member Avatar for iamthwee

Iamthwee, kicking somebody into a new thread is not very funny, neither is your avatar and your location. I have enjoyed many of your contributions in the past, but this one fails.

Member Avatar for thunderstorm98
0
120
Member Avatar for Lardmeister

At least they are using their money for a constructive project, rather than killing, maiming and bombing.

Member Avatar for vegaseat
0
28
Member Avatar for csy

[quote=EnderX;457897]Given that it's Lardmeister saying it, and his responses elsewhere in this forum, I'm assuming he was mixing them with 'Liberty Cabbage' (aka sauerkraut).[/quote] Clearly a major mistake by Lardmeister, here is the official story ... [quote] On [URL="http://en.wikipedia.org/wiki/March_11"][U][COLOR=green]11 March[/COLOR][/U][/URL] [URL="http://en.wikipedia.org/wiki/2003"][U][COLOR=green]2003[/COLOR][/U][/URL], [URL="http://en.wikipedia.org/wiki/United_States_House_of_Representatives"][U][COLOR=green]Representatives[/COLOR][/U][/URL] [URL="http://en.wikipedia.org/wiki/Bob_Ney"][U][COLOR=green]Robert W. Ney[/COLOR][/U][/URL] ([URL="http://en.wikipedia.org/wiki/Republican_Party_%28United_States%29"][U][COLOR=green]R[/COLOR][/U][/URL]-[URL="http://en.wikipedia.org/wiki/Ohio"][U][COLOR=green]Ohio[/COLOR][/U][/URL]) and [URL="http://en.wikipedia.org/wiki/Walter_B._Jones"][U][COLOR=green]Walter B. Jones[/COLOR][/U][/URL], …

Member Avatar for Lardmeister
0
137
Member Avatar for manishdhelia

Check the spelling of 'folder' ... [code=python]mytype = ikmo.getObjectType() print mytype # see if returns 'Folder' or 'folder' if(ikmo.getObjectType() == 'Folder'): sReturnURL = 'Present?object=1.11.1234' else: sReturnURL = 'Present?object=%s' % (oid) [/code]

Member Avatar for vegaseat
0
98
Member Avatar for sreejithps

Might be your spelling, in one case you have it listed as .\Templates\html\temlate1.html the error shows '.\Templates\html\template1.html'

Member Avatar for vegaseat
0
114
Member Avatar for thunderstorm98

From a google by redmarvel ... [QUOTE] A program is never finished until the programmer dies. A paperless office has about as much chance as a paperless bathroom. A user friendly computer first requires a friendly user. Bad or missing mouse driver. Spank the cat [Y/N]? Best file compression around: …

Member Avatar for Ezzaral
1
872
Member Avatar for The Dude
Member Avatar for jliu66

If you are uncomfortable with lambda, you can also use itemgetter() from the module operator ... [code=python]from operator import itemgetter first_list = [ " marek brutalski 20", "zenia markownikowa 10", "teresa parufkowa 90", "bogumila pierdawa 40", "genowefa tempawa 50"] second_list = [x.split() for x in first_list] # first column is …

Member Avatar for Lardmeister
0
169
Member Avatar for jliu66

One way to do this is using a high speed list comprehension ... [code=python]# combine two 2D lists using a list comprehension # a list is Python's more flexible array container a = [[1, 2, 3], [2, 3, 4], [3, 4, 5]] b = [[4, 5, 6], [6, 7, 8], …

Member Avatar for jliu66
0
742
Member Avatar for nitriles
Member Avatar for nitriles
0
123
Member Avatar for Agentbob

Most commonly used function ... [code=python]def int2bin(n): '''convert denary integer n to binary string bStr''' bStr = '' if n < 0: raise ValueError, "must be positive" if n == 0: return '0' while n > 0: bStr = str(n % 2) + bStr n = n >> 1 return …

Member Avatar for vegaseat
0
173
Member Avatar for jobs

[code=python]# set is builtin starting with Python24 new_list = [2,34,5,5,6,6,7,2] print new_list # [2, 34, 5, 5, 6, 6, 7, 2] new_set = set(new_list) print new_set # set([2, 7, 34, 6, 5]) [/code]Shorter ... [code=python]# use set() to make a list unique, order is lost mylist = [2, 34, 5, …

Member Avatar for vegaseat
0
614
Member Avatar for The Dude

[quote=cscgal;453565]At that point just wait a couple of years for the inheritance.[/quote]Shades of [B]Anna Nicole Smith?[/B]

Member Avatar for twomers
0
113
Member Avatar for The Dude
Member Avatar for Lardmeister
0
63
Member Avatar for jobs

[code=python]# %r uses repr() and %s uses str() # for example ... print "%r tag requires exactly two arguments" % "this" print "%s tag requires exactly two arguments" % "this" """ my output --> 'this' tag requires exactly two arguments this tag requires exactly two arguments """ [/code]

Member Avatar for vegaseat
0
89
Member Avatar for bumsfeld

Thanks G-Do for your information, so NumPy eventually replaces Numeric and Numarray. Interesting! When I was coding in C, I used to sample lab data and put it into a circular or ring buffer to keep the thing from overflowing. This was an easy way to calculate a moving average. …

Member Avatar for vegaseat
0
13K
Member Avatar for The Dude

[quote=jwenting;451918]I'd consider being locked up with Paris to be "cruel and unusual" punishment and therefore illegal... I'd rather be locked up in a fictional CIA torture prison than that.[/quote]Very funny! Paris must have some redeeming features though! I am too old for that! In some countries a thief looses a …

Member Avatar for lasher511
0
204
Member Avatar for Asif_NSU

Here is the way I figured it out: Let's say 5! = 1 * 2 * 3 * 4 * 5 the 1 drops out then 5! = 2 * 3 * 4 * 5 apply the log operator log(5!) = log(2) + log(3) + log(4) + log(5) for(j = …

Member Avatar for roxanne_gem07
0
279
Member Avatar for jobs

Be careful with a slice copy ... [code=python]old_list = [1, [2, 3,[4]], 5] new_list = old_list[:] # now change old_list old_list[1][0] = 1111 print old_list # [1, [1111, 3, [4]], 5] print new_list # [1, [1111, 3, [4]], 5] oops! [/code]If you want to make a copy of a list, …

Member Avatar for jrcagle
0
110
Member Avatar for Duki
Member Avatar for Lardmeister
0
107
Member Avatar for jrcagle

Even though Python has // as an integer division operator, I most commonly use the / operator. Right now you can use the / or the // operator for integer divisions, and here is were I get into trouble. [code=python]a = 4/5 print a # oops the result is 0 …

Member Avatar for jrcagle
0
100
Member Avatar for MrShoot

[quote=MrShoot;446737]Interesting, could you explain me a bit this part? [code=python]conv_list +=[el.lower()][/code] What exactly would the += do there?[/quote]This is just a shorthand of ... [code=python]my_list = ["CANADA", "HELLO", "I TOLD YOU SO"] conv_list=[] for el in my_list: conv_list = conv_list + [el.lower()] print conv_list """ my output --> ['canada', 'hello', …

Member Avatar for Ene Uran
0
161
Member Avatar for Eclipse77

Welcome to DaniWeb! Python's syntax might be easy for a beginner, but you have to remember that Python's power comes from knowing which of the many modules to use to make coding easier. In your case the module time will save you a lot of time (no pun intended). With …

Member Avatar for jrcagle
0
174
Member Avatar for use4d

I suspect that it is the trace fluorides in the salt. Everytime I go to the dentist, she smears some fluoride paste on my teeth, and now I have hair growing between my teeth.

Member Avatar for efmesch
1
97
Member Avatar for twomers

Skydivers can achieve a maximum of 120 mph during the free fall part of their dive. So 130 mph is a real achievement!

Member Avatar for jasimp
0
132
Member Avatar for slunk

Just remember that the first time a function is invoked/called, its code gets loaded into memory. If you give an argument a default that is mutable, you have to be aware of how that will behave. In practice, most of the time you won't do a default with a mutable. …

Member Avatar for jrcagle
0
760
Member Avatar for tesak

This happens with many computer languages. You are trying to compare floating point values directly. Your 0.8 might be more like 0.799999999999999 and the compare flunks! You can make this work by giving it a range you can compare within ... [code]if 0.79999 < status < 0.80001: ... do something` …

Member Avatar for jrcagle
0
106
Member Avatar for Roadphantom13

I am not familiar with this old graphics module, but generally you draw the face inside a rectangle/frame/canvas and move the whole rectangle/frame/canvas around.

Member Avatar for vegaseat
0
144
Member Avatar for ndoe

We need to see some code so we figure out which GUI toolkit you are using and which picture format you want to load.

Member Avatar for vegaseat
0
223
Member Avatar for sayanriju

Here would be a typical example ... [code=python]# experiments with wx.StaticText(), set a font for the text import wx class MyFrame(wx.Frame): def __init__(self, parent, id, title, data): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, size=(500, 380)) panel = wx.Panel(self, -1) # font type: wx.DEFAULT, wx.DECORATIVE, wx.ROMAN, wx.SCRIPT, wx.SWISS, wx.MODERN # slant: wx.NORMAL, …

Member Avatar for vegaseat
0
1K
Member Avatar for dcleaner

An interesting project, it will force you to learn three languages (Python, HTML and XML) all at the same time. Python has quite a number of XML related modules. Your project might be more a string handling project though.

Member Avatar for dcleaner
0
283
Member Avatar for RaDeuX

Two comments: 1) pack() does not have row and column, that is for grid() 2) do not mix pack() and grid() in the same frame

Member Avatar for vegaseat
0
434
Member Avatar for thunderstorm98

Don't know why, but it makes my heart beat better: "A Whiter Shade Of Pale" by Procol Harum

Member Avatar for lasher511
0
156
Member Avatar for Jon Pierce

Thanks for the info, there is always room for one more good example to learn from!

Member Avatar for vegaseat
0
150
Member Avatar for zagrijs

For posting Python code on Daniweb: Please use the [B][noparse][code=python][/noparse][/B] and [B][noparse][/code][/noparse][/B] tag pair to enclose your python code. Another note: Also make sure that the thread's title has something to do with your problem.

Member Avatar for zagrijs
0
110
Member Avatar for AnjaliThukral

Check the "Open Graphics Library" (OpenGL), there is a Python wrapper for it called PyOpenGL. VPython (VisualPython) might be easier to deal with: [URL]http://vpython.org/[/URL] Here is a VPython example ... [code=python]# a simple red cylinder in space # experiments with visual Python (VPython) # download from: [url]http://vpython.org/[/url] import visual as …

Member Avatar for AnjaliThukral
0
298
Member Avatar for deck55

Do you want to break the list into 2 lists at a set index? [code=python]file = ['S','D','S','D','S','D','N','S','D','S','D','N'] break_index = 6 list1 = file[:break_index+1] list2 = file[break_index+1:] print list1 print list2 """ result --> ['S', 'D', 'S', 'D', 'S', 'D', 'N'] ['S', 'D', 'S', 'D', 'N'] """ [/code]

Member Avatar for deck55
0
92
Member Avatar for jobs

Once you get familiar with constructs like list comprehension, they become quite easy to read. List comprehensions also give quite an improvement in speed too.

Member Avatar for vegaseat
0
363
Member Avatar for Salem

Maybe, when they cut the throats of the goats, some sacrificial blood spattered onto the plane's loose wiring and made it hold its contact. No, it was most likely the god of flight and fertility. Neat title for the thread Salem!

Member Avatar for Ravenous Wolf
0
122
Member Avatar for laseredd

I use both DrPython (Windows and Linux) and PyScripter (Windows). DrPython needs wxPython and is very stable, relies on plugins for advanced features. PyScripter comes as an .exe file (written in Python for Delphi) and has some excellent features out of the box. The one I like is that it …

Member Avatar for freddypyther
0
237

The End.