3,386 Posted Topics

Member Avatar for jcomputing

I think the editing should not take on share but should be copied to share after editing is finished, then there is not temp file in share. Each user could have own subfolder as mentioned allready.

Member Avatar for SudoWin
0
147
Member Avatar for prettyspinster
Member Avatar for prashanthmukund
Member Avatar for G_S
Member Avatar for G_S
0
8K
Member Avatar for Frensi

name = input("What is your full name: ").title() if name in ("John Cleese", "Michael Palin"): print("I do not like your name") elif name == "Jack Neilson": print("That's a very nice name") else: print("You have a nice name")

Member Avatar for TrustyTony
0
153
Member Avatar for Ancient Dragon

I think it is usually quite opposite: it looks little strange to look some old newbie posts, when the poster has hundreds of posts and current signature by retroactive use of current info, and especially time they have now been members. Could it be easily changed to put the time …

Member Avatar for TrustyTony
0
208
Member Avatar for TrustyTony

What this produces and why? >>> a = 2 >>> b = 5 >>> exec "print(a+b)" in dict(a=6, b=9)

Member Avatar for TrustyTony
1
185
Member Avatar for zmjman08
Member Avatar for HankReardon

Considering the [almost ready answer given by your teacher](http://www.daniweb.com/software-development/python/threads/426980/cant-use-variable-outside-of-for-loop#post1827205) (even giving suggestions, against the common naming conventions of Python, but anyway, about names of variables) I for one do not feel like telling you ready answer. You were allready given advice about return value of function in the other thread.

Member Avatar for TrustyTony
0
104
Member Avatar for HTMLperson5

You have infinite recursion. What is wrong with Python itself? You could disallow the dangerous '_' character, though, for safety. Maybe only eval is OK. If you need control flow you must go with exec.

Member Avatar for HTMLperson5
0
1K
Member Avatar for Dani
Member Avatar for vy_007

You can find tons of exmple code from http://www.daniweb.com/software-development/python/threads/191210/python-gui-programming And Python code snippets tab.

Member Avatar for TrustyTony
0
5K
Member Avatar for Acidz

Nice to hear about your triumpf! Maybe it was good lesson for you to formulate clearer question, and to make it possible for others to run your code, next time. If you want to be nice to others proper Daniquette is to post your solution, if it is free to …

Member Avatar for Acidz
0
356
Member Avatar for HTMLperson5

line 60 condition is always True as `or "some not empty string"` is never False value

Member Avatar for HTMLperson5
0
272
Member Avatar for ashine80
Member Avatar for Dani

It was nice to have back even based on it, even I have not much chance of being appreciated of my[ prime code snippet](http://www.daniweb.com/software-development/python/code/425958/prime-starting-numbers) given the 4 year old newbie post it compares it to!

Member Avatar for ndeniche
1
217
Member Avatar for Dani

For me it is little confusing as actual edit window has kind of *half preview* with the markup also showing. Also when the post is long and I am using mobile, even only to edit small typo, it is making it harder than necessary. Mostly it is OK, but not …

Member Avatar for Dani
0
335
Member Avatar for Testa

Keep lower and higher bounds both in variables, which you update by user response for random, and call it only in one place in loop.

Member Avatar for Testa
0
214
Member Avatar for trishtren
Member Avatar for TrustyTony
0
286
Member Avatar for ashine80
Member Avatar for ashine80
Member Avatar for Reverend Jim

And for any youngster not familiar of this GOTO statement (or am I only too optimistic?), here the classic document from archives of Computer Science history: https://files.ifi.uzh.ch/rerg/arvo/courses/kvse/uebungen/Dijkstra_Goto.pdf

Member Avatar for MosaicFuneral
0
355
Member Avatar for werydude
Member Avatar for HTMLperson5

OK, here for you start: from __future__ import print_function try: input, range = raw_input, xrange except NameError: pass def quit_(): raise SystemExit def plus(a, b): return int(a)+int(b) commands = {'echo':print, 'quit':quit_, '+':plus} while True: c = input('>>').split(None, 1) if len(c) == 2: c, args = c args = args.split() elif …

Member Avatar for Gribouillis
0
330
Member Avatar for TrustyTony
Member Avatar for Ene Uran
0
208
Member Avatar for sneekula

On the Python front there could be worse things to do than to check about Sugar on sugarlabs.org. http://sugarlabs.org/ In addition to being Python based and open source (ever listened "read the source"? And Python source is really easy to read when done well) there is also the Smalltalkish [Etoys](http://activities.sugarlabs.org/fi/sugar/addon/4030) …

Member Avatar for Sanchixx
0
482
Member Avatar for vallarakesh
Member Avatar for fatalaccidents

Check [she-bang line](http://en.wikipedia.org/wiki/Shebang_%28Unix%29) in your script

Member Avatar for TrustyTony
0
189
Member Avatar for TrustyTony

What is prefered version on handling 'serialized' code snippets, with features added to previous post? I have posted a [polynomial expression snippet](http://www.daniweb.com/software-development/python/code/425151/class-based-polynomials-with-magic-methods#post1817526) to which I could not include the division part because original poster whose thread inspired me to start, have not proved finding his solution to the problem. Should …

Member Avatar for TrustyTony
0
230
Member Avatar for KY_Fan
Member Avatar for hughesadam_87

As this is not performance critical code, this kind of place is one of those that I sometimes like to use the functional map invocation of function to all items: >>> ''.join(str(i)for i in range(10)) '0123456789' >>> ''.join(map(str, range(10))) '0123456789' >>>

Member Avatar for TrustyTony
0
124
Member Avatar for sparsh610

You do not read singly linked list backward, that is why it is called singly linked. You would basically need to build another singly linked list reversed while reading the list from front to back. The process would be same as not in place reversing the linked list function uses.

Member Avatar for mike_2000_17
0
852
Member Avatar for 4evrmrepylrning

I do not know how much this fuss is worth, looks like you are basically just after simple Python one-liner: >>> d = 'ABC <uvw <xyz some random data' >>> import string >>> print([w for w in d.split() if w.startswith('<') and len(w)==4 and all(c in string.ascii_lowercase for c in w[1:])]) …

Member Avatar for TrustyTony
0
212
Member Avatar for TrustyTony

Do you get content of oper right before trying it out? oper = ['plus', 'minus', 'times'] oper.extend('divide') How about do you know what happens when you run this? Big bang? ;) print('a' 'b' 'c') And this is same, isn't it`? c = 'c' print('a' 'b' c)

Member Avatar for snippsat
1
185
Member Avatar for chophouse

> "C:\\Dir1\\Sub One\\Sub3\\Sub4\\Sub Five\\logfile.txt" Why are you using different names for logfile in the two different opens? Isn't it supposed to open file in same location?

Member Avatar for chophouse
0
239
Member Avatar for TrustyTony

Here you see how one could use recursion together with generators for (inefficient) permutations generator. It is kind of interesting to know how one can do it recursively (of course there exist many ways). Anyway this snippet demonstrates how you can use recursive generator call to feed a for statement. …

0
435
Member Avatar for prashanthmukund

Look into using list comprehesion or basic for loop with append. There is also map function that would fit your case but now the prefered way are the more versatile list comprehensions.

Member Avatar for Lucaci Andrew
0
403
Member Avatar for Dani

I think there must be certain part of newbies that we can not change from one google wonders. I think we need certain number of atypical oldies who do not stop learning and maybe somebody else could take my path to learn by "when you do not know you teach" …

Member Avatar for TrustyTony
0
956
Member Avatar for TrustyTony

I googled little around for correct way to not reinventing of the wheel for expression evaluation (even I had done some simple evaluation check for my [Tkinter calculator snippet](http://www.daniweb.com/software-development/python/code/282548/simple-calculator) earlier). After getting totally upset with [this example](http://www.bestcode.com/html/evaluate_math_expressions_pyth.html), I made this with some struggles with `__builtins__` globals parameter of eval. First …

0
642
Member Avatar for TrustyTony

I am trying to write safyfied evaluator class, and get unexpected `__builtins__` added to dictionary after evaluation. Can somebody explain why/how it happens? import math def echo(n): print n return n def nothing(n): return n debug = nothing class MathParser(object): ''' Mathematical Expression Evaluator class. call evaluate() function that will …

Member Avatar for HiHe
0
308
Member Avatar for shibu2all

Do small array, say four elements and write to paper changed values after each line of code.

Member Avatar for TrustyTony
0
229
Member Avatar for Lucaci Andrew

More general snippet on the same subject can be found at [scan filetree for files containing text](http://www.daniweb.com/software-development/python/code/316585/scan-filetree-for-files-containing-text)

Member Avatar for TrustyTony
0
319
Member Avatar for lewashby

a = q*b + r, where 0<=r<b, then a/b=q and r is the remainder, for example 5 = 2 * 2 + 1 so 5/2=2 and 5%2=1

Member Avatar for TrustyTony
0
173
Member Avatar for merse

Can you give example/timing data of your problem? Maybe you should read up on premature optimization? Int type is supposed to be most optimal in every platform.

Member Avatar for L7Sqr
0
126
Member Avatar for Gribouillis

This snippet could probably be good foundation for file copy/installation with progress bar by adding function to call for each block. It could take parameters for current block number and total number of blocks.

Member Avatar for Gribouillis
3
4K
Member Avatar for sebass123

main is not void and you have not defined add and add1, a and b are uninitialized... you have not enough formats for your parameters in printf.

Member Avatar for dheaven
0
186
Member Avatar for mohsin1992

I think you can not add characters to empty string passed to function in C. This would seem to work: #include<stdio.h> #include<string.h> void recurse(const char *, int); int main() { const char *charset="abcdefghij"; recurse(charset, strlen(charset)); } void recurse(const char *charset, int len) { int i; if(len>1) recurse(charset, len-1); for(i=0; i …

Member Avatar for Trentacle
0
2K
Member Avatar for reddsoxy

%s, not %r: str not repr. height = raw_input("How tall are you? ") print "So, you're %s tall." % height

Member Avatar for reddsoxy
1
186
Member Avatar for Marco25Me

This kind of situation is usually dealt with design pattern called delegation, but maybe better way is to isolate common functionality to separate class and inherit from it to both classes.

Member Avatar for TrustyTony
0
95
Member Avatar for new_developer

Actually I could not find any object oriented code in your post, so no methods also.

Member Avatar for Lucaci Andrew
0
167

The End.