2,646 Posted Topics

Member Avatar for Faro_1

You can write the reset function like this def reset(self): global number, tries number = random.randrange (100) + 1 result_msg = "Game reset. Start guessing!!!" tries = 0 self.update_display(guess='', result=result_msg, tries='') where the `update_display()` method fills the Text widgets def update_display(self, **kwargs): for key, display in self.display_map.items(): if key in …

Member Avatar for Faro_1
0
357
Member Avatar for Sean___

It looks quite simple. You need to add an attribute to dungeon items, such as `GoldValue: 25,`. From the character's point of view, you can invent a new variable similar to location or inventory, such as `purse = 18` which means that you have 18 gold coins. In `do_buy()`, you …

Member Avatar for Gribouillis
0
627
Member Avatar for Nazneen_1

@alc6379 The code reads a list of file names in an excel (xlsx) file. The image files (.jpg) are displayed in a resizable window and the video files (mp4) are played in an external process with a player named omxplayer. As this thread is 6 months old, I suspect Nazneen_1 …

Member Avatar for alc6379
0
559
Member Avatar for sekmani

This is a long post and there are many questions. Let's first start with a simple code that waits for console input with a timeout. A correct way to do it is by using `select.select()`. from select import select import sys def main(): timeout = 5 print('Please type something: ', …

Member Avatar for sekmani
0
2K
Member Avatar for Siberian

You wrote `raw_input(nameAsk)` instead of `raw_input('What is your name')`. I would also use a while loop. The idiom `while True` means *repeat indefinitely*, so my loop runs until the `break` statement exits the loop. The advantage is that I don't have to write the `raw_input()` statement twice. while True: name …

Member Avatar for Gribouillis
0
241
Member Avatar for Sumit_12

See how your code looks better after I used the [astyle](http://astyle.sourceforge.net/) beautifier astyle --style=python --align-pointer=middle --max-code-length=79 atm.c For human readers, formatting matters in programming #include<stdio.h> #include<conio.h> void main() { float bal=0,dep=0,withd=0; int n1,n2; clrscr(); do { clrscr(); printf("\n\t\t************************\t\t\n"); printf("\t\tWelcome To ATM Services\n"); printf("\t\tSelect Your Choice:\n"); printf( "\t\t1)Deposit Cash\n\t\t2)Withdraw Cash\n\t\t3)Bank Statement\n\t\t4)Fast …

Member Avatar for Gribouillis
0
1K
Member Avatar for Robbert

The tread must also be created by [code=python] thread1 = threading.Thread(target = stringFunction, arg = ("one", my_queue)) [/code] and not threading.Thread(stringFunction("one", my_queue)).

Member Avatar for sekmani
2
29K
Member Avatar for TrustyTony

@jklotzner Thank you for the input, but this has nothing to do with today's python vs yesterday's python. The difference is that your code is written in the local namespace of a `main()` function while pyTony's code is written in the global namespace. A python program does not need a …

Member Avatar for Gribouillis
0
5K
Member Avatar for Plinth

I think he means **indentation** instead of deviation. Python's success is amazing in this thread! I think the best reason for a beginner to choose python is that it is one of the fastest ways to obtain concrete results without learning a bunch of theoretical computer science. A second reason …

Member Avatar for diafol
0
512
Member Avatar for mohammed_41

The way you wrote the code snippet, it works only if `data_file.txt` is in the current working directory. A solution is to use the full path to the data file. If the data file is in the same directory as the python script, you can also use import os filename …

Member Avatar for Gribouillis
0
219
Member Avatar for lewashby
Member Avatar for vegaseat

@Stuart_5 PySide is a third party module that needs to be installed separately. See https://pypi.python.org/pypi/PySide

Member Avatar for Gribouillis
3
2K
Member Avatar for adanaz

@DubWine hi, it seems that there are solutions by using the `ctypes` module and the `setconsolewindoinfo` method in windows api. See https://stackoverflow.com/questions/3646362/how-to-control-the-size-of-the-windows-shell-window-from-within-a-python-script for example. Also google the keywords python and setconsolewindowinfo. Edit: you can also read the console dimension without a subprocess as in http://rosettacode.org/wiki/Terminal_control/Dimensions#Python

Member Avatar for DubWine
0
18K
Member Avatar for lewashby
Member Avatar for rproffitt
0
2K
Member Avatar for Adm666

I think you need a file `complex.h` containing the line void read_comp(complex, int, int);

Member Avatar for kristiangd
0
505
Member Avatar for Eric_8

I think you get this error because of `with open(f, 'r') as var1`. It should be `with open(os.path.join(destdir, f), 'r') as var1`. A more up-to-date approach is to use module [pathlib](http://docs.python.org/3/library/pathlib.html) from pathlib import Path destdir = Path('pathtofile') files = [p for p in destdir.iterdir() if p.is_file()] for p in …

Member Avatar for Eric_8
0
14K
Member Avatar for Ehsanullah_1

Don't learn software development, instead 1. Find something useful that you want the computer to do for you. 2. Find whatever way to obtain this from the computer. 3. That's it, you are a software developer! Do you really think Bill Gates learnt software development ?

Member Avatar for Gribouillis
0
191
Member Avatar for Violet_82

I just found a straightforward python app named seqdiag to generate sequence diagrams, see [blockdiag.com/en/seqdiag/examples.html](http://www.blockdiag.com/en/seqdiag/examples.html)

Member Avatar for Violet_82
0
417
Member Avatar for Eric_8

Which value is not passed to the function ? Is it the call to `processFile(x)` ? Did you try to add statements such as `print(sys.argv[1:])` before line 21 or `print(x)` at the beginning of `processFile()` ? You could use my printat snippet to help you debug this https://www.daniweb.com/programming/software-development/code/479747/print-with-line-and-file-information Some remarks …

Member Avatar for Eric_8
0
331
Member Avatar for Nether_1

> The only problem I'm encountering is that I cannot create enough names for all of this by hard-coding it I'm not sure I understand this question very well. It seems to me that you want to create many instances of a certain class but you don't want to create …

Member Avatar for Gribouillis
0
566
Member Avatar for kiyo_1
Re: how

Because of operator precedence, the first if is equivalent to if ((matirial == 'maths') or ('math') or ('Maths') or ('Math') or ('رياضيات')): The result of the or .. or .. or .. or is the first non false term, that is to say the string `'math'` unless the user enters …

Member Avatar for samson.dadson.3_1
0
232
Member Avatar for kiyo_1

It is because after `age = raw_input('...')`, age is a character string. It needs to be converted to an integer like this age = raw_input ('enter you age-->') age = int(age)

Member Avatar for Gribouillis
0
221
Member Avatar for Katarína_1

I recommend using the built-in csv module to read csv files. You can simply use import csv with open('eggs.csv', newline='') as csvfile: spamreader = csv.reader(csvfile, delimiter=',') data = [row[3:] for row in spamreader] print(data)

Member Avatar for Gribouillis
0
240
Member Avatar for john_beginner

Also see [url=http://www.daniweb.com/code/snippet232375.html]this thread[/url] about the format method for python >= 2.6.

Member Avatar for Reverend Jim
0
21K
Member Avatar for gunjan_3

Normally, the exception traceback that python prints on the screen tells you the line number and statement where the error occurred. Can you post the whole traceback ?

Member Avatar for Gribouillis
0
274
Member Avatar for dhani09

This code does not throw a KeyError, it only defines two classes and does nothing.

Member Avatar for Emma Etigu
0
1K
Member Avatar for happygeek
Member Avatar for Dani

Hm, I'm having an issue with the fullscreen mode in the awesome [qutebrowser](http://www.qutebrowser.org) browser: the F11 key is already bound to toggle the browser's fullscreen mode, and the Esc key is bound to exiting the insert mode. It means that I can't exit the editor's fullscreen mode. Can't you add …

Member Avatar for Dani
6
1K
Member Avatar for S._1

Can you add enough code so that we can have the button that calls the `resize()` function and try it ourselves and reproduce the error ?

Member Avatar for Gribouillis
0
2K
Member Avatar for Vanessa_1

I don't understand the statement that this python code takes multiple parameters nor how it could take only one parameter. Can you elaborate on this so that everybody understands what you want ?

Member Avatar for Gribouillis
0
346
Member Avatar for zac202020

@prince_16 Many python snippets written 7 years ago were written in python 2. That's why they don't work out of the box in python 3. However they can be easily adapted to python 3 with minor changes or with the help of the 2to3 tool. It is not useful to …

Member Avatar for Gribouillis
0
4K
Member Avatar for Gribouillis

This snippet defines a function restart_program() which restarts your python program from within your python program.

Member Avatar for Gribouillis
5
75K
Member Avatar for Tcll
Member Avatar for Nether_1

Here is an experiment in the python console >>> s = raw_input('Please Enter Password: ') Please Enter Password: Nether >>> s 'Nether' You see that the string has been stripped of the `\n` character. It means that you could define thelist = ['Nether'] One usually avoids `list` as a variable …

Member Avatar for Gribouillis
0
371
Member Avatar for ayushi_3

The import statement is the mechanism that allows python programs to use libraries. Using libraries is a key feature in any programming language. It allows our programs to benefit from all the work that has been done before by others. Suppose you're a clever mathematician and you write a python …

Member Avatar for hastings.george.5
0
217
Member Avatar for dinilkarun

I don't think it is possible. Using `pydoc openpyxl.load_workbook` shows a `read_only` option but no `write_only` option. It seems to exist only for new workbooks. I think using large excel files is questionable. Why not write a csv file with python, then perhaps convert it to xlsx through other tools …

Member Avatar for ddanbe
0
2K
Member Avatar for Hi

The trick is often to convert the number to a float >>> ispeed = 1 # <--- integer speed >>> fspeed = 0.5 # <--- float speed >>> sspeed = "0.8" # <--- string speed >>> ispeed = float(ispeed) >>> fspeed = float(fspeed) >>> sspeed = float(sspeed) >>> print(ispeed, fspeed, …

Member Avatar for ddanbe
0
665
Member Avatar for Tcll

At the end of the wiki page on [rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix), there is a link to the [Rodrigues rotation formula](https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula). This could be what you're looking for.

Member Avatar for Tcll
0
595
Member Avatar for Violated

The `except` keyword can occur only in a `try` statement, and must have the same indention as the preceding `try`. try: statement statement statement except ValueError: statement statement Also, this is not an error, but the traditional style in python is to indent code with 4 spaces (and not 1 …

Member Avatar for rproffitt
0
184
Member Avatar for Dani
Member Avatar for tofi

This small [tutorial](https://pymotw.com/3/csv/) will teach you how to read and write csv files with python. You can post your code here if there are issues.

Member Avatar for tofi
0
344
Member Avatar for ddanbe

There is also an implementation at [Rosetta code](https://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation#C.23). It is very short, but I haven't used C# for a long time, so I don't know if it is good.

Member Avatar for ddanbe
0
885
Member Avatar for massivefermion

Of course it is possible, third party modules need to be installed with a tool such as pip, then they can be imported. For example if we want to use module `unidecode` that we find in the [python package index](https://pypi.python.org/pypi/Unidecode), we can open a terminal (or cmd console) and type …

Member Avatar for pty
0
514
Member Avatar for Sergio_5

Usually you don't do it, you read and parse the input file by various means, for example >>> import io >>> stdin = io.StringIO("""34 78""") >>> line = stdin.readline() >>> line '34 78' >>> x, y = (int(s) for s in line.split()[:2]) >>> x, y (34, 78) You could perhaps …

Member Avatar for Reverend Jim
0
246
Member Avatar for glao

I'd recommend using `python setup.py develop` first, which will install a symbolic link allowing python to import and use myapp without really installing the package. If you're using a virtualenv, make sure the command uses your virtualenv's python interpreter.

Member Avatar for glao
0
299
Member Avatar for Shidong

Anyway, I won't use vim nor spacevim as long as they don't have a serious support for the bépo keyboard.

Member Avatar for Gribouillis
0
328
Member Avatar for giancan

This is a windows issue, so I cannot help you much, furthermore, it seems to be a python 2 issue only. You could try solutions such as [<this one>](http://stackoverflow.com/questions/846850/read-unicode-characters-from-command-line-arguments-in-python-2-x-on-windows) for example. The best thing to do is probably to move to python 3. Try with your install of python 3 …

Member Avatar for Gribouillis
0
392
Member Avatar for Gurpinder

The home site www.python.org has a special [page for beginners](https://www.python.org/about/gettingstarted/) with good links, you could perhaps start from here. Concerning your specific code, without entering into details * At line 2, input() returns a value: the user's answer. You're ignoring this value. * At line 5, `if expression` is always …

Member Avatar for Gribouillis
0
314
Member Avatar for yaldoo

Well, `range(10)` contains the numbers `0 1 2 3 4 5 6 7 8 9` while `range(10, 110, 10)` contains `10 20 30 40 50 60 70 80 90 100` which is whats the program purports to convert.

Member Avatar for yaldoo
0
703
Member Avatar for lewashby

Try `which pip` and `which python`. Both should be in your virtual env's `bin` directory. `django-admin.py` should be in the same directory. You can also use `locate django-admin.py` to find all the files with that name in your file system.

Member Avatar for lewashby
0
554

The End.