Software Development
Member Avatar

hi , I am trying to write " hi " in persian using unicodes like this :
print('\uFEB3\uFEFC\uFEE1') but it prints from the left side and in reverse order like …

Topic by fonzali

There might be a Persian version of Python.

Software Development
Member Avatar

Hello friends :)
This is my code:

#!/usr/bin/env python3
# -*-coding: utf8-*-

def callback():
    lbl.configure(text = 'button clicked!')

import Tkinter

window = Tkinter.Tk()
window.geometry('300x300')
window.configure(background = 'PeachPuff3')
lbl = Tkinter.Label(window, …
Topic by Niloofar24

Normally you build a house from the bottom up. Try to understand the basics of Python first and put the windows in later.

Community Center
Member Avatar

A cat has 9 lives -- what has more than 9 lives?

Answer:

Frogs because they croak every night. (Duck Dynasty)

Topic by Ancient Dragon

I had a power outage at my house this morning and my PC, Laptop, TV, DVD, IPad and my new surround sound music system were all shut down.

Then I …

Community Center
Member Avatar

The strange title comes from a skit by Benny Hill, where he tells his wife all the facts she shouldn't know, but she always answers "I know! I know!"

Anyway, …

Topic by vegaseat
Computer languages Worldwide, Jan 2015
Meassured by the number of inquiries on Google
(a mixture of "I am interested" and "I am lost")
----------------------------------------------------
Rank   Language     Share(%)  Trend(% vs a …
Information Security
Member Avatar

I got infected right after a Java and Adobe update on my Windows7 machine.
folder \jnihmpibahpjjmcodbopcpdaelkbpjnc is most likely a random generated folder.

Note on malware PriceLess (pops up as …

Topic by sneekula

Update:
PriceLess has so far stayed away from my Chrome Web Browser extensions. However I can still find references to it, for instance if I save a file without extension …

Software Development
Member Avatar

Hi everybody!
How can i call a function from Tkinter without using Buttons?
I have a test.py file and there is a function def message in it:

def message():
    print('Good …
Topic by Niloofar24

Try it this way:

''' favemovies.py

with iPython on Windows use:
run C:\Python27\Atest27\Bull\favemovies.py view
'''

import sys
import pickle
# for Python3 replace Tkinter with tkinter
import tkinter as tk …
Community Center
Member Avatar

I'm hoping that people will post unusual or little known facts here. It would be proper to include a link to a source for confirmation. Here's a start.

Speedy Gonzales …

Topic by Reverend Jim

After the Swiss Federal Bank floated the Swiss Franc against the Euro, the Franc shot up so much that many Swiss take the short trip to Germany to literally buy …

Software Development
Member Avatar

Hi everybody!
How can i call a function from Tkinter without using Buttons?
I have a test.py file and there is a function def message in it:

def message():
    print('Good …
Topic by Niloofar24

Then you have to change your code to:

def message():
    label['text'] = 'Good morning'

# for Python3 replace Tkinter with tkinter
import Tkinter as tk

win = tk.Tk()

label = …
Software Development
Member Avatar

Hi everybody!
How can i call a function from Tkinter without using Buttons?
I have a test.py file and there is a function def message in it:

def message():
    print('Good …
Topic by Niloofar24

Try:

def message():
    print('Good morning')

from Tkinter import *
tk = Tk()
message()
tk.mainloop()
Software Development
Member Avatar

Hello friends.
I want to create a list of sublists
E.G.

i = 0
pack = []
list = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
while i < 17:
    sublist = list[list[i]: list [i + …
Topic by kouty

Apply append() this way:

i = 0
pack = []
mylist = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
while i < 17:
    sublist = mylist[i : i + 3]
    pack.append(sublist)
    i += 1
print (pack)
Software Development
Member Avatar

Hello friends.
I want to create a list of sublists
E.G.

i = 0
pack = []
list = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
while i < 17:
    sublist = list[list[i]: list [i + …
Topic by kouty

Avoid using Python function names like list for variable names.

if you use
list = [1, 2, 3]
and later
abc_list = list('abc')
it won't work!

Software Development
Member Avatar

Hello!
I have a file with a list and 3 functions in it; view, append and sort functions.
I want to use pickle to save data changes in to another …

Topic by Niloofar24

I would use with, it closes your files properly. Also use a protocol for larger files:

import pickle

fname = "films.db"
with open(fname, "wb") as fout:
    # default protocol is …
Software Development
Member Avatar

This simple isprime(number) function checks if the given integer number is a prime number and returns True or False. The function makes sure that the number is a positive integer, …

Topic by vegaseat

A simple timing example:

import time

def print_timing(func):
    """
    a decorator function to time another function
    time.clock() works on Windows systems only
    you can use time.time() instead, but it gets …
Software Development
Member Avatar
## solution 1: fast enough response, simple function, fail fast
from time import clock
def isanaword(k,s):
    """ goes through the letters of second word (s) and returns it
        if first …
Topic by marcelocent

To work with the clipboard see:
https://www.daniweb.com/software-development/python/code/487653/access-the-clipboard-via-tkinter#post2142575

Software Development
Member Avatar
## solution 1: fast enough response, simple function, fail fast
from time import clock
def isanaword(k,s):
    """ goes through the letters of second word (s) and returns it
        if first …
Topic by marcelocent

What operating system are you using?

Software Development
Member Avatar

Hi.....I am a newbie...really confused with do while loop in python. Does it even exist?

[CODE]
J=[]
do:
finished = "false"
while finished != "true":
finished="true"
for j in xrange(len(lis2)): …

Topic by shafter111

The elegant thing about the while True loop is that you can break at a given point between statements.

Software Development
Member Avatar

Hello Daniweb!
I learn in the Computer Sciences Circle, Click Here
in the chapter 8.
there strings, for exemple "sse" and "assessement" or "an" and "trans-panamian bananas", and we just …

Topic by kouty

Note that overlapping subs won't work with text.count():

text = "assesses"
sub = "sses"

print(text.count(sub))  # --> 1 ???
Software Development
Member Avatar

Hello Daniweb!
I learn in the Computer Sciences Circle, Click Here
in the chapter 8.
there strings, for exemple "sse" and "assessement" or "an" and "trans-panamian bananas", and we just …

Topic by kouty

I took the liberty to time some of the approaches:

''' str_count_sub_timing_hperf.py
timing functions that count the number of sub_strings in a string
using high performance time.perf_counter() 
new in Python …
Software Development
Member Avatar

i did these function for uppercase:

string Upper(string text)
{
    string result;
    result.resize(text.size());
    for(int i=0; i<text.size(); i++)
    {
        if(text[i]>96 && text[i]<123)
            result[i]= text[i]-32;
        result[i]=text[i];
    }
    return result;
}

but i'm …

Topic by cambalinho

You can modernize this a little:

// str_toupper.cpp
// convert a string to all upper case
// compiled with mingw32-g++.exe

#include <algorithm>  // transform()
#include <cctype>     // toupper()
#include <iostream> …
c++
Community Center
Member Avatar

I know this sound weird but What will happen if the earth fell into the sun some kids say why does the moon not fall down well thats a beautiful …

Topic by RobertHDD

Slowing down the Earth to a speed that would make it fall into the Sun within a few days time, would flatten it like a ripe tomato hitting a wall.

Software Development
Member Avatar

After you got the basics of Python under your belt, the best way to get a good knowledge of the language and improve your coding skills is to start on …

Topic by vegaseat

If you go to:
http://en.wikipedia.org/wiki/List_of_countries_by_inflation_rate
you can extract the 10 countries with the highest inflatuion rate.

You end up with this tab delimited data string:

data = '''\
Uruguay 8.11 …
Community Center
Member Avatar

The strange title comes from a skit by Benny Hill, where he tells his wife all the facts she shouldn't know, but she always answers "I know! I know!"

Anyway, …

Topic by vegaseat

10 countries with with the highest mid 2014 inflation rate:

Country Inflation (%)
Venezuela 60.9
Sudan 46.8
Belarus 32.8
Argentina 24.2
Iran 14.6
Syria 13.6
Ukraine 13.0
Egypt 10.61
Turkey …

Community Center
Member Avatar

I know this sound weird but What will happen if the earth fell into the sun some kids say why does the moon not fall down well thats a beautiful …

Topic by RobertHDD

What external force could slow down the Earth orbital speed?

Software Development
Member Avatar

Is it possible to solve this problem in c++?
Write a program that counts the numbers from 3 to 117. But for multiples of three add 3 instead of 1 …

Topic by ivel

You have this execution/evaluation order:
1) if (i%3 == 0 && i%5 == 0)
2) else if (i%3 == 0)
3) else if (i%5 == 0)
4) else

Here 2) …

c++
Software Development
Member Avatar

Hello Daniweb!
I learn in the Computer Sciences Circle, Click Here
in the chapter 8.
there strings, for exemple "sse" and "assessement" or "an" and "trans-panamian bananas", and we just …

Topic by kouty

Hmm:

''' str_find_sub_index.py
explore
s.find(sub[ ,start[,end]]) returns index or -1
'''

text = "trans panamanian bananas"
sub = "an"

start = 0
count = 0
while True:
    ix = text.find(sub, …
Software Development
Member Avatar

Is it possible to solve this problem in c++?
Write a program that counts the numbers from 3 to 117. But for multiples of three add 3 instead of 1 …

Topic by ivel

@ivel
I looked at the code you have written and at NathanOliver's helpful suggestions. I came to the conclusion that you need beginner's help.

I took your code and corrected …

c++
Software Development
Member Avatar

i did these function for uppercase:

string Upper(string text)
{
    string result;
    result.resize(text.size());
    for(int i=0; i<text.size(); i++)
    {
        if(text[i]>96 && text[i]<123)
            result[i]= text[i]-32;
        result[i]=text[i];
    }
    return result;
}

but i'm …

Topic by cambalinho

@cambalinho
you are mixing char and int types, do the proper casts and your approach will work:

// str_Upper.cpp
// convert a string to all upper case

#include <iostream>
#include …
c++
Software Development
Member Avatar

i did these function for uppercase:

string Upper(string text)
{
    string result;
    result.resize(text.size());
    for(int i=0; i<text.size(); i++)
    {
        if(text[i]>96 && text[i]<123)
            result[i]= text[i]-32;
        result[i]=text[i];
    }
    return result;
}

but i'm …

Topic by cambalinho

Something like that:

// removes the third bit, simple way to create upper case char
char toupper(char ch)
{
  return ch & 0xDF;
}

Sorry doesn't handle numbers etc.

c++
Software Development
Member Avatar

After you got the basics of Python under your belt, the best way to get a good knowledge of the language and improve your coding skills is to start on …

Topic by vegaseat

Write a Python program that checks a given directory for any file changes over a given period.

Software Development
Member Avatar

Hi everybody.
How can i creat e text file to use as a database in python?
I want to save my project's data changes into hard disk. What should i …

Topic by Niloofar24

Give us a short example of what your project data looks like.