3,386 Posted Topics
Re: Do shallow copy of input list as list is mutable by slice [:] or .copy() method call. | |
Re: You have code instead of code tag in **String Formatting with Dictionaries** | |
Re: Looks like the doctest can not handle def statements from log of IDLE command prompt. [CODE]C:\py>script_from_examples.py ex2.txt def sum(a,b): # Expected: ## return a+b C:\py>type ex2.txt >>> def sum(a,b): return a+b [/CODE] Plain CMD Python prompt shows it differently: [CODE]>>> def sum(a,b): ... return a+b ...[/CODE] | |
Re: Something like yEd?http://www.yworks.com/en/products_yed_about.html | |
Re: You should post only relevant part where you have trouble. | |
Re: tuples of function calls without using their return values here are very strange for me def openFiles(selection): if selection == "animation": saveAnim(), animation() if selection == "compositing": saveComp(), compositing() return | |
Re: Most natural way is list comprehesion. http://www.pythonforbeginners.com/lists/list-comprehensions-in-python/ | |
Re: Maybe you should try specialist forums or Stack Overflow to find expert on the subject: http://r-dir.com/community/forums.html | |
Re: Maybe you should simply recode the app? Here my example gmail sending snippet in Python: http://www.daniweb.com/software-development/python/code/380881/python-3-and-python-2-send-email-through-gmail | |
Re: We do not understand as the tree has single cargo contents, nothing about expressions. You must include example data also, output you get for that and the desired result. | |
Re: Here is your print function transformed to conform common style rules of PEP8 from __future__ import print_function class Customers(object): def __init__(self, sur_name = None, first_name = None, address = None, town = None, post_code = None, phone_number = None, date = None, email = None): self.sur_name = sur_name self.first_name = … | |
Re: Consider if you are dealing with single word or set of words belonging in classes. Also think is it better to go through the words in file and find where they belong or look for words that belong to some class for each class? I think you must loop over … | |
Re: Variable even is not defined. | |
Re: There seems to be already many discussions about this in net, by quick Google, maybe this could help you: http://stackoverflow.com/questions/2564137/python-how-to-terminate-a-thread-when-main-program-ends | |
Re: GFF is undefined and indentation of line 4 is misindented. | |
Re: Why you want unbalanced " and what is the logic? Why such stupid format, sorry to ask? | |
Re: `artist_string.upper() or artist_string.lower() not in line` Should be as per Gribouillis explanation `artist_string.upper() not in line and artist_string.lower() not in line` And so on. But probably it should be so that you make: `artist_string.lower() not in line.lower()` | |
Re: Why you are using StringIO here? Just build the string normally and send it. Python pseudo-code: send_mail(address, subject,'\n'.join(info_i_want(big_file) for big_file in list_of_files if size_of(big_file) > SIZE_LIMIT) | |
Re: Line six is opening the file sample.txt as many times as there is files in dir without saving it for later use. I think that is not what you are after. The error simply says that such file as does not exist, but it is strange that it is missing … | |
Re: You are changing input function to mean input values hiding the original meaning. Your approach should work even if it is not ideal. Using index position loops is also ugly and it is better to iterate over items in for loop. Things get much clearer once you learn about functions … | |
Re: Par is parameter of function print_func residing in module support. | |
Re: Unfortunately I do not understand your algorithm. I have one snippet I have posted connected with file tree walking, if you like to check it: http://www.daniweb.com/software-development/python/code/316585/scan-filetree-for-files-containing-text | |
Re: The writing style is clear and crisp, but I would prefer turtle graphics code to be more sparing of gotos, even they are not program gotos. Usually you do routine so that is relative to turtle direction and maybe returns to starting position. Then you could just loop colors, turn … | |
Here some old fashioned line input routine, better idea nowadays would be to use GUI input box with real editing. Anyway, it is quite simple with Python to do this basic routine for terminal based program. | |
Re: Do you mean that you can not explicitly change to string like: #!/usr/bin/env python3 import sys file = sys.argv[1] f = open(file, 'rb') f.seek(-125, 2) artist = f.read(30) newartist = str(artist, 'UTF8').rstrip('\x00') print(new) f.close() | |
Re: I wrote one code snippet on line input with reenter possibility today. http://www.daniweb.com/software-development/python/code/479987/simple-line-input-with-reentering-possibility-unlimited-lines | |
Re: Gribouillis surely can come out with something, ask more specifically. Here his earlier post containing importing ast, response to my code snippet: http://www.daniweb.com/software-development/python/code/389822/averaging-iterable-without-making-copy-of-values#post1680277 | |
Re: Have you read this tutorial article? http://www.daniweb.com/software-development/c/tutorials/45806/user-input-strings-and-numbers-c | |
Re: \x00 is byte, not 4, you can strip those with `.rstrip('\x00')` >>> b'Rooster\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 'Rooster\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' >>> _.rstrip('\x00') 'Rooster' >>> | |
Re: You have list with value for while condition, which is never empty, so this while never terminates in case of not found. Remove [] No need to shout with CAPITALIZEd words. | |
Re: http://www.tkdocs.com/tutorial/windows.html | |
Re: I can not understand what you are after, this does not sound like problem of finding the correct algorithm for problem, it sounds more like you already have the pseudo code algorithm given to you. | |
Re: Maybe I am bit dense, but I do not know what you are after. Here is my own quadratic solver in code snippets: http://www.daniweb.com/software-development/python/code/356952/pep8-quadratic-equations-solver | |
Re: Sorry, we are not psychic, could you post relevant piece of your code and clear question (with error messages included) | |
I did code for challenge that I saw posted for C# by deceptikon: http://www.daniweb.com/software-development/csharp/threads/479304/coding-challenge-string-to-date Here it is. Of course normally the code would be without prints and put in function, but this is enough for now for me. There could also be normalization from '/' separated form not producing ambiguous … | |
Re: I wonder what you want to do for the array, why you want to change it to worse representation? You can easily count/filter number with numpy functions. Have you read/browsed the [relevant numpy documentation](http://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html)? http://docs.scipy.org/doc/numpy/reference/routines.sort.html Tony | |
Re: You have read http://wiki.wxpython.org/wxPython%20by%20Example#A_Full_Example , haven't you? | |
If I want to search for some tag, and I have not any so tagged post in front of me, how I open posts with that tag? I know that if I have one similarly tagged I can only click the tag. | |
Re: > global tot_words tot_words = len(words_dict) global correct correct = 0 These declarations do not make sense as they are on top level, not inside function. If you must use globals, put them at very beginning of functions. Usually classes are better option. I rearrange your lines standard way and … | |
Re: I would get rid of the glob.glob totally as we deal only with ends. filenames = [path for path in os.listdir(directory) if path.endswith(('.py', '.txt'))] | |
Re: Here is example code printing selected file: [CODE]import os from Tkinter import Tk import tkFileDialog toplevel = Tk() toplevel.withdraw() filename = tkFileDialog.askopenfilename() if os.path.isfile(filename): for line in open(filename,'r'): print line, else: print 'No file chosen' raw_input('Ready, push Enter') [/CODE] | |
I am looking for alternatives to setup a server in work place which does not allow to setup new software to computers to check and reserve rooms for meetings both through local network computers or possible from home / on the move. I of course would like to have thy … | |
Re: Looks little like prolog, I see that first is out of bounds base case, others area the recursion cases. [Here]( http://stackoverflow.com/questions/10063516/list-length-inserting-element) is discussion how in Prolog you would define inserting, maybe it gives you some help. You would only need to check that length of beginning part is asked number, … | |
To continue[ my quiz series](http://www.daniweb.com/search/query/0?q=%22quiz+of+the%22+pytony#gsc.tab=0&gsc.q=%22quiz%20of%20the%22%20pytony&gsc.page=1), explain what happens with this code (how you would name this action and is there other way to get same result), why, and what is actually the value of `a` at end. a = ['a', 'b','e'] a[2:2] = ['c', 'd'] | |
Re: http://lmgtfy.com/?q=binary+numbers | |
Re: ...and you do have to deal with wrap around from z to a,b,c.. | |
Re: The loop counter in Vegaseat's code should not be x and the assignment should be moved out of the loop # Tkinter animate via canvas.move(obj, xAmount, yAmount) import Tkinter as tk import time root = tk.Tk() canvas = tk.Canvas(root, width=400, height=400) canvas.pack() # canvas.create_rectangle(x0, y0, x1, y1, option, ... ) … | |
Re: Please use Code from the posting menu and post your code inline. Make first not growing snake, the add collision detect. Basically list of places where snake is could be good idea, then you just remove one end and add one cordinate for head, when snake grows you leave the … | |
Re: Import should be mostly at beginning, so import application class Mapsframe(wx.Frame): def __init__(self): pass class Example(wx.Frame,listmix.ColumnSorterMixin): def __init__(self, *args, **kwargs): super(Example, self).__init__(*args, **kwargs) self.InitUI() def InitUI(self): pass def onItemSelected(self,event): frame = Mapsframe() application.one_function(frame) #e.g. |
The End.