3,386 Posted Topics

Member Avatar for piethon

True never becomes False or similar False-like value so the loop continues until break statement or exception inside loop.

Member Avatar for GreenDay2001
0
1K
Member Avatar for TrustyTony
Member Avatar for Archenemie
1
705
Member Avatar for Niner710

Without re, if surely good format: [CODE]>>> blah = """vcc = 2.6, clock = 1.5 Mhz vcc = 2.7, clock = 1.6 Mhz vcc = 2.8, clock = 1.7 Mhz vcc = 2.9, clock = 1.8 Mhz""" >>> blah = [line.split() for line in blah.splitlines()] >>> blah [['vcc', '=', '2.6,', …

Member Avatar for TrustyTony
0
185
Member Avatar for Lolalola

You should launch it in thread and kill it if result is not ready after 3 seconds. It more likely means that you have bad design for the function. What you want to do?

Member Avatar for TrustyTony
0
196
Member Avatar for mikedeomon

You should use open instead of file at line for list_of_names: listofnames = file('twit.txt').readlines() listofnames = [name.strip() for name in listofnames] #--> list_of_names=[name.strip() for name in open('twit.txt')] But actually in code you only use it once, so making the list is kind of wasteful, generator would suffice: for name in …

Member Avatar for woooee
0
198
Member Avatar for clickspiker23
Member Avatar for shurshot

input takes every kind of Python expression and evaluates them. It should not be used and therefore it is removed from Python3. Format %.2f means: put here the variable after string and % with two fixed decimals format (like natural for currency).

Member Avatar for TrustyTony
0
353
Member Avatar for mchin131
Member Avatar for WolfShield

Maybe you can find something from here: [url]http://www.lisp.org/alu/res-lisp-tools#guitool[/url]

Member Avatar for WolfShield
0
576
Member Avatar for sidra 100

Think of what you have done before and what mistakes you did and why, how you succeeded and reasons for that. Do plan to avoid mistakes and do one better in successful strong points. The project work is other pro(cess/blem). After this you realize that you realy should really understand …

Member Avatar for Rashakil Fol
0
352
Member Avatar for flebber

Yes you can nest, but your request does not take one, only conditional expression in value part: [CODE] [x*x if x % 2==0 else x * 3 for x in range(1,20)][/CODE]

Member Avatar for richieking
0
156
Member Avatar for gendler.max

GPL Octave is supposed to be mostly matlab compatible [url]http://en.wikibooks.org/wiki/MATLAB_Programming/Differences_between_Octave_and_MATLAB[/url]

Member Avatar for shiva07
0
141
Member Avatar for eman 22

[url]http://en.wikipedia.org/wiki/Cycle_detection[/url] It includes code implementations in Python. It is not about graphs specifically, but functions. For graphs you can find for example: [url]http://en.wikipedia.org/wiki/Cycle_space[/url]

Member Avatar for shiva07
0
79
Member Avatar for hughesadam_87

Here is snippet of vegaseat in his sticky thread, how to use matplotlib and tkinter, maybe you can apply the example.

Member Avatar for hughesadam_87
0
118
Member Avatar for yuvalm2
Member Avatar for asrockw7

I know this is C forum but I would like to bring up a point that programming is not language. Generally programmers can say: "I know this language best but I can learn any language others use, programming is programming." (most people have actually strong preferance, I for example generally …

Member Avatar for asrockw7
0
427
Member Avatar for Vengful

Another while loop around the line 20 would be clearer, although it is possible to just generate new value for x after response to continue and not to do the break.

Member Avatar for Vengful
0
96
Member Avatar for tubby123

Sorry, but I do not love doing string processing in C. You could do manual PATH processing or find library to support that for you in C. Or you could find way to retrieve it from System Registry ([URL="http://lateblt.tripod.com/prgw32rg.htm"]with winreg.h[/URL]).

Member Avatar for TrustyTony
0
91
Member Avatar for silvercats
Member Avatar for cesione

That code of Schoil-R-LEA has bug in ranges (try str2int('98789', 10) for example) but if you take right interpretation as pseudocode, it will work for you.

Member Avatar for N1GHTS
0
2K
Member Avatar for debasishgang7

What you want to do with that strange line as strings have not method called accept?

Member Avatar for Tech B
0
1K
Member Avatar for TrustyTony

Next quiz is posted as code snippet. It is quite interesting code. What it does? And where [B]in your system[/B] you already have this code? (in little different format) (If you have not follow tip in page [url]http://python.org/download/[/url])

Member Avatar for TrustyTony
0
230
Member Avatar for celestial_sea

So you are looping your [B]output[/B].txt with [B]i[/B]fp looks illogical naming. Why 'a' mode for ofp? (which is never used) Why lines 11 to 14 and at least why a<20 and b<20 and line 9 says char data[8][8][3]?

Member Avatar for Adak
0
146
Member Avatar for Tomashqooo
Member Avatar for tlox

You do not need database for simple phone dictionary, but if there is some usefull source of information, where information is always updated, it could be usefull to draw information there to avoid out of sync problems with not up to date info. Any language can handle it, spreadsheet is …

Member Avatar for Adak
0
382
Member Avatar for peter20

For DOS there is for example the trusty old [URL="http://en.wikipedia.org/wiki/Turbo_Vision"]Turbo Vision.[/URL]

Member Avatar for TrustyTony
0
69
Member Avatar for Checkerboz

How abot divmod or modulo % and integer division // ? You might find reading my base conversion snippet helpful. You can also make the str(n)[::-1] work by doing [CODE]' '.join(str(n)[::-1])[/CODE]

Member Avatar for Checkerboz
0
121
Member Avatar for Thropian

Use functools.partial: [CODE]import functools def f(x): print(x) thislist = range(10) actions = [functools.partial(f, x) for x in thislist] for action in actions: action() [/CODE]

Member Avatar for Thropian
0
76
Member Avatar for ankurvit

I do not know, but I have coded the longest common substring algorithm and mayby you could use similar dynamic programming approach. [url]http://www.daniweb.com/software-development/python/threads/284870/1245223#post1245223[/url]

Member Avatar for TrustyTony
0
196
Member Avatar for clyt

Only line that could happen is line 2, if you have empty first line. You could change it to [CODE]ncols = len(rows[1])[/CODE] if second line is not empty

Member Avatar for clyt
0
138
Member Avatar for Tugnus

Here you find tutorial for both Python2 and Python3: [url]http://python.org/doc/[/url] DaniWeb is great place to learn Python: [url]http://www.daniweb.com/software-development/python/threads/20774[/url] After these tutorials you should find out secrets of Python which your teacher has hidden from you :icon_rolleyes:

Member Avatar for Tech B
0
2K
Member Avatar for FALL3N

This looks like worthy read: [url]http://jimmyg.org/blog/2009/working-with-python-subprocess.html[/url]

Member Avatar for FALL3N
0
116
Member Avatar for Hawkwing

Only this works: [CODE]class someclass: def __init__(self): self.somevariable='somevalue' def somefunction(self): print('gotta get here') def someotherfunction(instance): instance.somefunction() myclass=someclass() someotherfunction(myclass)#this needs to print 'gotta get here' [/CODE] as myclass.somevariable is only one string and has nothing connection with someclass. Or must save self in init: [CODE]class someclass: def __init__(self): self.somevariable= self, 'somevalue' …

Member Avatar for woooee
0
162
Member Avatar for dgreene1210

Also, do you see something strange in here? [CODE]/* Return Value: returns statement in parenthesis. */ void greeting ()[/CODE]

Member Avatar for TrustyTony
0
267
Member Avatar for btowne2

I have simple algorithm for you ;) [LIST=1] [*]Learn to think [*]Learn basic math [*]Learn software design [*]Learn C++ [*]Learn to use IDE [*]Learn to debug [/LIST] Points 4, 5 and 6 need actually some parallel processing :)

Member Avatar for Lerner
0
191
Member Avatar for arshi9464

Your question seems upside down: "How I can use this solution, which does not work or does not work allways, to problem I have which I do not tell to you"

Member Avatar for TrustyTony
0
151
Member Avatar for sharathg.satya

For me this is only way (OS uses of course loop): [CODE]#include <stdio.h> #include <stdlib.h> int main() { int n; char range[298] = " 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99"; printf("Number between 1 and 99: "); scanf("%2d", &n); if(n > 99 && n < 1) { printf("Not …

Member Avatar for bajishareef
0
274
Member Avatar for Caraka

May you tell, why you need single quotes, which you can do many ways, including repr function?

Member Avatar for Caraka
0
869
Member Avatar for cheenu02

I think you run circles: if you want to know how much *int increase by pointer increment in a C implementation it is equivalent to finding [B]sizeof int[/B] which is easy to find and there must be one standard constant for that defined somewhere.

Member Avatar for bajishareef
0
2K
Member Avatar for bangor_boy
Member Avatar for TrustyTony
0
141
Member Avatar for jmark13

Grib has fine idea, but you should check that first value does not inadvertedly become neighbour of last value (maybe it is allready, I do not catch your rules so well) Here more incomplete parsing with itertools.groupby, leaving list one level: [CODE] import itertools def is_bracket(c): return c in '[]' …

Member Avatar for TrustyTony
0
139
Member Avatar for Petan Kl
Member Avatar for FALL3N

[CODE]variable = 'testF' def testF(): print('Hello World!') def reflect(what): globals()[what]() def main(): reflect(variable) main() [/CODE] I did not get any error message like you said however, only complaint of trying to use string as variable after fixing the missing :, usually we however do not use string to pass, but …

Member Avatar for FALL3N
0
279
Member Avatar for TrustyTony

The code demonstrates running program limitted time by following going over endtime expressed in seconds since midnight, so might fail for playing just midnight (add check that endtime is less than 24*60*60 if you want to be sure). Exciting action :) of the program is that it shows remaining time …

0
447
Member Avatar for FALL3N

Show what you trying to do, we need more information about what error you are getting with what data and by what code you trying to accomplish and what you want to accomplish.

Member Avatar for snippsat
0
114
Member Avatar for mariko

There is some unique dangers in doing scripptig as well as benfits (of course if you do Python). But you really can not generalize as it not only depends on programming language and nature of program but also clarity of mind and expression of the writer. By the danger I …

Member Avatar for vegaseat
0
165
Member Avatar for TrustyTony

I thought to post some not quite so trivial as it looks quiz for Python, to test if your brain has Python installed OK ;) Try to figure out what interpreter answers (#? lines), then check with your Python interpreter of choice: [CODE]>>> a = list(range(10)) >>> a[1:1] #? >>> …

Member Avatar for TrustyTony
3
673
Member Avatar for Kirielson

What is purpose of replacing the parent class with instance of child class at line 5? I do not understand how it would function. Your first error message looks incomplete.

Member Avatar for griswolf
0
342
Member Avatar for hszforu

Maybe most of activist have 2.6 (for psyco etc) and 2.7, maybe 3.2 installed. Also you could use portable version of some of them. Notice that 2.7 is quite much faster than 2.6 without psyco (often both faster than Python3). Also PyPy JIT compiler (written with subset of Python) is …

Member Avatar for hszforu
0
194
Member Avatar for TrustyTony

There was little buggy version of Python base conversion around, so here quick hack for my own program, including test with random numbers to verify it.

Member Avatar for TrustyTony
0
930

The End.