123 Posted Topics
Re: this is the problem [code] grade = input("Enter gradepoint for course (Enter to quit): ") [/code] input() expects a number. when you just press enter, it gives error maybe a try:except can solve the problem... | |
Re: [QUOTE=Matt Tacular;294741]is there an easy way to detect if the entire contents of one list are in another? if I have a list like this: li = [1,2] and I have another which will have random values, I want the program to do something only if every value of li … | |
Re: [code] def en_de_code(text,flag=0): if flag == 0: return ''.join([chr(ord(char) + 1) for char in text ]) #encode else: return ''.join([chr(ord(char) - 1) for char in text ]) #decode [/code] | |
Re: how about trying the set_debuglevel() method in smtplib [URL="http://docs.python.org/lib/SMTP-objects.html"]http://docs.python.org/lib/SMTP-objects.html[/URL] | |
Re: [QUOTE=sharky_machine;284046]Is it then the [I][B]keys[/B][/I] of the dictionary that are immutable? Not the entire dict? I have read about this much and many sources claim that Python dicts "are immutable." I just did a search again about dicts, and came upon a page that claims that "lists are immutable" :rolleyes: … | |
Re: [QUOTE=Matt Tacular;283452]I would post this in my other thread, but I marked that as solved so I think less people would look at it. I want to say this: [code]if list1 is empty: do this elif list1 has any value in it: do this[/code] How do I word that in … | |
Re: [QUOTE=cambrian;283486] from Tkinter import * import math ##import sys sys.frozen = 1 ..... [/QUOTE] do you want to comment out "import sys" and try again? | |
Re: Its all in the docs. Here it is: [URL="http://docs.python.org/ref/types.html"]http://docs.python.org/ref/types.html[/URL] under the heading "Sequences" | |
![]() | Re: you can use maketrans and translate to create the lookup table eg usage [code] import string letters = string.ascii_lowercase key = 13 trans_table = letters[key:] + letters[0:key] trans = string.maketrans(letters,trans_table) text = "i am crazy" print text.translate(trans) [/code] output: [code] 'v nz penml' [/code] For newer version of Python, there … |
![]() | Re: [QUOTE=LaMouche;266366]say you have a list: [php] list = [1,a,2,b,3,c,4,d,5,e,6,f,7,g,8,h,9,i,10,j,11,k,12,l,13] [/php] What's the easiest loop set up if I want to store each number (every other slot) into another list? The above list is actually text from a file read and then split with "1 a" and such on each line … |
Re: [QUOTE=sneekula;265297]I thought function xrange would give me a list of integers, but I got a string instead: [code]x = "xrange(1, 5)" print x # xrange(1, 5) x = xrange(1, 5) print x # xrange(1, 5) same result as string above!? [/code][/QUOTE] if you look at the xrange() docs. it says … | |
Re: [QUOTE=pfunix;259584]Greetings All! I would like to get some feedback to all ya good python folks here at daniweb regarding some implementations that you guys doing with Python and using MySQL db. I'm looking for some mysql plugin for python. I've tried sourceforge 's mysql-python but with no luck(installing) .. maybe … | |
Re: it's best if you could explain what you wish to do, give sample input and output if possible | |
Re: [QUOTE=etxulid;257977]Maybe my question was a little bit wrong. I would like to reverse a nibble. I have a dodgy solution but it works... Now I have a different issue. I would like temp1psc : ['\xc7', 'g', '\xea'] to look like ['\xc7g\xea'] Any ideas?[/QUOTE] ''.join(['\xc7', 'g', '\xea']) | |
Re: [QUOTE=Matt Tacular;253843]Is there a way though, to make it also scan sub directories?[/QUOTE] Just an example only: [code] import os allfiles = [] #store all files found for root,dir,files in os.walk("C:/Documents and Settings/Matt/Desktop"): filelist = [ os.path.join(root,fi) for fi in files if fi.endswith(".doc") or fi.endswith(".txt") ] for f in filelist: … | |
| |
Re: you could try this: [code] >>> a = unichr(275).encode('utf8') >>> b = a.decode('utf8') >>> b u'\u0113' >>> ord(b) 275 [/code] | |
Re: [QUOTE=chris99;254239]Fixed it! Here's the new code: [CODE]#1337 to Human dictionary: leet={"1337":"l-EET/nReally Awesome","noob":"(n00b) nOOb\nPerson who can't accept that s/he's wrong", "-xxors":"Suffix, pron: zors.\nUsed to accent an important verb, e.g. roxxors", "newb":"new-b,\nPerson who is new to a game and needs help. Not to be\nconfused with noob"} word=1 while word not in ("","0"): … | |
Re: [QUOTE=chris99;250950]Unique random variables. I've tried modifying the code in varying ways, but nothing is working. The program won't add new numbers to replace the ones that were duplicates. [CODE]import random b=0 numbers=[] print "show 6 random unique integers from 1 to 50: " while b < 6: for k in … | |
Re: [QUOTE=V KUMAR]At local machine, How to zip a file at remote location using scripting in batch file[/QUOTE] if your remote system runs telnet, you can use the Perl's telnet module to telnet to remote system, gzip the file and return to calling script. | |
Re: [QUOTE=butterflyTee]# sum.py # tpm # A program that accepts an indeterminate (any number) of integers entered by # the user, calculates and their sum, using loop [CODE]from math import * def calc_sum(): n = input("Enter any number: ") sum = 0.0 for i in range(n): x = input("Enter a number … | |
Re: [QUOTE=pare80]Hello to all, I am trying to create a script that will go through certain directorys in Windows and pull out the files I stated by extentions. Which will then later copy to a location either on the local machine or an external HD. Any assistence will be greatly appricated. … | |
Re: [QUOTE=Ene Uran]I am fairly familiar with C, but new to Python. Does Python have something like the handy C conditional expression? For example: [code]// C conditional expression x = a ? b : c; // if a is true then x = b else x = c // here used … |
The End.