Posts
 
Reputation
Joined
Last Seen
Ranked #33
Strength to Increase Rep
+16
Strength to Decrease Rep
-4
98% Quality Score
Upvotes Received
1K
Posts with Upvotes
1K
Upvoting Members
383
Downvotes Received
26
Posts with Downvotes
25
Downvoting Members
16
250 Commented Posts
~3.79M People Reached
About Me

Mind explorer.

Interests
Logic, psychology, mathematics.
PC Specs
Kubuntu 16.04 Xenial Xerus
Favorite Tags

2,646 Posted Topics

Member Avatar for Steph102

Here is a very different solution (the bitCount() function comes [from here](http://wiki.python.org/moin/BitManipulation), it counts the number of bits set in an integer) import random def bitCount(int_type): count = 0 while(int_type): int_type &= int_type - 1 count += 1 return(count) tails = bitCount(random.getrandbits(100)) :) It is probably much faster.

Member Avatar for Dani
0
16K
Member Avatar for Tuấn_4
Member Avatar for vegaseat

@urireo561 You can use pythonmagick or another imagemagick python binding to resize the image. See this snippet for example https://www.daniweb.com/programming/software-development/code/463880/resize-an-image-with-pythonmagick

Member Avatar for CodeWorked
1
22K
Member Avatar for daviddoria

This is what I have [code=python] >>> from wxPython.wx import * __main__:1: DeprecationWarning: The wxPython compatibility package is no longer automatically generated or actively maintained. Please switch to the wx package as soon as possible. >>> import wx >>> [/code]

Member Avatar for Reverend Jim
0
2K
Member Avatar for nunos

HTML is a special case of XML, the difference is that in an XML file, you can have arbitrary tags, like [icode]<nunos>hello</nunos>[/icode]. So, if a library can parse XML, it can also parse HTML and other specialisations of XML, like MATHML, etc. That's why most libraries are designed for XML. …

Member Avatar for r8lst
0
812
Member Avatar for linux

[QUOTE=docdawning;1059689]Sure Python requires memory management, but if you provide a bare-metal type OS beneath the interpreter, somewhat like how BIOS provides a compatibility layer, then you could set out to write an OS that's extremely heavily implemented with Python. Still, doing so would require an intimate understanding of the plumbing …

Member Avatar for Thulan
2
2K
Member Avatar for danibootstrap

I suppose that you can obtain the implementation of `ioctl()` by downloading the source code of the `glibc` library [http://ftp.gnu.org/gnu/glibc/](http://ftp.gnu.org/gnu/glibc/).

Member Avatar for Bazirao
0
1K
Member Avatar for soibac

see [this thread](http://www.daniweb.com/software-development/python/threads/463434/pyqt4-problem). It looks like the same issue.

Member Avatar for RespectedCow
0
10K
Member Avatar for joe82

> I also want to remove header line (first line) and want to catenate rest of the lines. This code removes the first line of a file and prints the rest, concatenated whith open("myfile.txt", "rb") as ifh: next(ifh) # skip first line print(''.join(x.rstrip('\n') for x in ifh)) # read the …

Member Avatar for vishakha_3
0
23K
Member Avatar for adam291086

Because as you defined it, send_SMS is a method of the class sendmessage. So when you call [icode]x.send_SMS('error')[/icode], 2 arguments are passed, the first is [icode]x[/icode], the other is [icode]'error'[/icode]. There are 2 solutions, either you add an argument: [icode]def send_SMS(self, message):[/icode], or, if you don't need the instance, you …

Member Avatar for chethan_2
0
14K
Member Avatar for tony75
Member Avatar for Andreas_7
0
22K
Member Avatar for jozz3
Member Avatar for Smartfitness33
0
8K
Member Avatar for ZZMike

Standard builtin functions have been tested gazillion times by programs all around the world. It is almost impossible that you discover an unknown bug in them. `strip()` removes characters only at both ends of the string. You will have to use `replace()` >>> 'qazxswedc'.replace('x', '') 'qazswedc'

Member Avatar for tinstaafl
0
13K
Member Avatar for OsaMasw

It looks more like a windows question than a linux question. I think the [plink.exe ](http://the.earth.li/~sgtatham/putty/0.52/htmldoc/Chapter7.html) tool can execute remote commands through ssh.

Member Avatar for extr3mex
0
571
Member Avatar for majestic0110
Member Avatar for Baneeishaque
1
10K
Member Avatar for fifarulez

I've been learning python for more than 20 years. It is an endless quest.

Member Avatar for Amelia28
0
362
Member Avatar for vegaseat

There are [good functions](http://tnt.math.se.tmu.ac.jp/nzmath/manual/modules/prime.html) in the [nzmath](http://tnt.math.se.tmu.ac.jp/nzmath/) module. Here is a session with python 2.7 in linux >>> import nzmath >>> from nzmath.prime import primeq /usr/local/lib/python2.7/dist-packages/nzmath/config.py:328: UserWarning: no datadir found warnings.warn('no datadir found') >>> primeq(9999991) True >>> import timeit >>> find_function = 'from __main__ import primeq' >>> stmt = 'primeq(9999991)' …

Member Avatar for paddy3118
1
2K
Member Avatar for vegaseat
Member Avatar for amir_19
3
24K
Member Avatar for RAZ_2

You could use `itertools.groupby` and `collections.Counter`. Something along the lines of newip = [] c = Counter() for key, group in groupby(logfile, key=lambda e: e.split('.',1)[0]): for entry in group: c.update(re.findall(r'[0-9]+(?:\.[0-9]+){3}', entry)) newip.extend(ip for ip, cnt in c.items() if cnt > 10) c.clear() newblist = blacklist + newip The groupby() groups …

Member Avatar for tdsan
0
16K
Member Avatar for vegaseat

Here is a perhaps more readable version try: from Tkinter import * except ImportError: from tkinter import * import time root = Tk() clock = Label(root, font=('times', 20, 'bold'), bg='green') clock.pack(fill=BOTH, expand=1) def tick(): s = time.strftime('%H:%M:%S') if s != clock["text"]: clock["text"] = s clock.after(200, tick) tick() root.mainloop()

Member Avatar for Vinay_17
2
26K
Member Avatar for HiHe

This deserves an answer: ''' tk_button_toggle5.py ''' from functools import partial import itertools import sys python2 = sys.version_info[0] == 2 tk = __import__("tT"[python2] + "kinter") def toggle(button): button.state = not button.state button['text'] = str(button.state) def new_btn(state): btn = tk.Button(width=12) btn.state = bool(state) btn.config(text= str(btn.state), command = partial(toggle, btn)) btn.pack(pady=5) return …

Member Avatar for martineau
1
21K
Member Avatar for novice20

[QUOTE=novice20;1448561]And... import in script2 worked fine when mode_check() was defined before main. Please let me know, why is it wrong to define a function before main, if it is so? and why did it work now?[/QUOTE] Your problem is a circular import like this [code=python] # in module A import …

Member Avatar for Cisco_1
0
37K
Member Avatar for happygeek

I don't think it's correct to blame Google for Q&A sites' success. I think these sites meet a specific programmers' need: we want to use software and libraries and we don't have time to learn APIs or read every manual. So we need expert answers to specific use cases. The …

Member Avatar for Dani
10
3K
Member Avatar for HAMMAD_5

You can try [Qwant](https://www.qwant.com/) [Qwant](https://www.qwant.com/?q=foobar&t=all), although it is said to be bing + privacy.

Member Avatar for Christiana_1
0
1K
Member Avatar for usman_14
Member Avatar for Elizabeth_13

The problem is that you write `from tkinter import *` after `from graphics import *`. Some objects defined in the [graphics.py](https://pypi.org/project/graphics.py/) package get shadowed by objects defined in the tkinter package. In this case, the graphics.py [Text](http://mcsp.wartburg.edu/zelle/python/graphics/graphics/node11.html) class is shadowed by the tkinter [Text](http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/text.html) widget. The best thing to do …

Member Avatar for Gribouillis
0
775
Member Avatar for lewashby

The best layout for french is the [BÉPO](https://en.wikipedia.org/wiki/Keyboard_layout#B%C3%89PO) layout. Install it and switch the layout everytime you want to type in French.

Member Avatar for Gribouillis
0
901
Member Avatar for davy_yg

I don't know the answer, but this is what I read in django's documentation > It is always better for security to deploy your site behind HTTPS. Without this, it is possible for malicious network users to sniff authentication credentials or any other information transferred between client and server, and …

Member Avatar for Neena_3
0
500
Member Avatar for Basel_1

The first thing is to never have variable names containing a variable index, such as `product_1, product_2,` etc. Use lists or tuples instead pairs = [ ("Flake", 0.55), ("Wispa", 0.50),("Crunchie", 0.65), ("Milky Way", 0.35), ("Boost", 0.65) ] product, product_price = zip(*pairs) Then `product[0]` is `'Flake'`,` product[4]` is `'Boost'` and similarly …

Member Avatar for Reverend Jim
0
21K
Member Avatar for Tony_9
Member Avatar for Ankush_4
0
13K
Member Avatar for nadiam

Read the file by chunks and also write chunks: with open("portrait1.dng", "rb") as binaryfile : with open("readfile.raw", "wb") as newFile: while True: chunk = binaryfile.read(4096) if not chunk: break newFile.write(binascii.hexlify(chunk)) > my whole university life is on this (translation, if it dies i die). Make sure you backup your files …

Member Avatar for Gribouillis
0
54K
Member Avatar for Nicole_7

Before even thinking of using python for this, you need to define what the computer will do and what the human player(s) will do. You don't need a specific programming language for this.

Member Avatar for Gribouillis
0
795
Member Avatar for abders
Member Avatar for Kaushik_2
0
989
Member Avatar for random_1

In python 3, the value returned by `binascii.hexlify()` is a `bytes` instance instead of a `str` instance. As `setText()` is expecting a `str` instance, you need to convert hexadecimal to `str`. This is done by hexa_str = hexadecimal.decode('utf-8')

Member Avatar for Gribouillis
0
9K
Member Avatar for vegaseat
Member Avatar for Kippstah

@sam_38 Your question is way too vague. The best way to use a programming forum is to start your own thread and post code containing your attempts to solve the problem. If your question is about persisting data on disk, there is a builtin module `pickle` that can persist almost …

Member Avatar for balaji_8
-1
17K
Member Avatar for Tcll

Strange code and strange specifications as usual, but well ... Two points: 1. Why do you want the vector to hash as a tuple ? What's the use of this ? There must be a good reason as this breaks your code. 2. There is a serious drawback in your …

Member Avatar for Tcll
0
453
Member Avatar for Aman_14

The `sorted()` function has a boolean `reverse` parameter that allows to sort in descending order sorted(lines, key=itemgetter(3), reverse=True) This is much more efficient than trying to write your own quicksort method.

Member Avatar for pty
0
12K
Member Avatar for Nemius

For problem 1, I think you could remove the 'data' argument in def OnCellChange(self, evt, data): ... For problem 2, you need to compute the `row` value that you want to insert, for exemple def appendRow(self): row = self.GetNumberRows() # + 1 perhaps ? self.AppendRows(1) self.data.append((str(row), '', '', '', '', …

Member Avatar for Nemius
0
1K
Member Avatar for mattyd

@Madhu_6 It is permitted, but it does not have the meaning you expect. Here is an experiment >>> small_case = "abcdefghijklmnopqrstuvwxyz" >>> space = " " >>> camel_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" >>> "k" in [small_case, camel_case, space] False >>> "K" in [small_case, camel_case, space] False >>> "abcdef" in [small_case, camel_case, space] …

Member Avatar for rahul_64
0
53K
Member Avatar for Reverend Jim

No I've never seen a solution. That's one of the many features of windows that waste the user's time!

Member Avatar for diafol
1
502
Member Avatar for Ala'a99

Matplotlib can handle events such as keypress or mouse clicks. One only needs to write a few callbacks. Here is a small example adapted from the matplotlib's documentation. It first displays a curve, then, on a keypress event a second curve, then a third """ Show how to connect to …

Member Avatar for Gribouillis
0
454
Member Avatar for Tcll

Hi Tcll, it's been a while indeed! I don't think there is a flaw in python's descriptor implementation. Also I don't understand why you think there is a security issue nor which 'private object' is 'passed into your backend'. If Attr is a descriptor in the class, then indeed `Instance.Attr` …

Member Avatar for Tcll
0
462
Member Avatar for Nemius

Hi, it's been a long time since I last used wxpython, but I think it should be something like for i, seq in enumerate(data): for j, v in enumerate(seq): self.SetCellValue(i, j, v) You should find good examples in the Mouse vs Python series, which cover many things concerning wx python, …

Member Avatar for Nemius
0
2K
Member Avatar for reeta_1

**What have you tried?** This is what everybody wants to know when you ask a homework question. We don't know what you know about programming in python. Obviously you must have learned how to define a function, that's a starting point. Let's take it the other way around. If I …

Member Avatar for rubberman
0
333
Member Avatar for willygstyle

> I tried to make all the print statements python2/python3 compatible Do you know you can use from __future__ import print_function to get immediate compatibility ?

Member Avatar for Gribouillis
0
5K
Member Avatar for abders

The error 'TypeError: must be type, not classobj ' usually appears in python 2 when an old style class instance is used in a function where a new style class instance is expected. Aren't you using an old version of python where Tkinter classes are old style classes ? If …

Member Avatar for Gribouillis
0
2K
Member Avatar for Abdullah_17

Start by reading a list of names from a single file and print these names in the console. Post your code!

Member Avatar for Sue_2
-1
358
Member Avatar for ztdep
Member Avatar for Gribouillis
0
350
Member Avatar for lewashby

Is there a `setup.py` file in the extracted hierarchy? If so, open a terminal (cmd window), go to the directory where the setup.py file is and type `python setup.py install`. Before that, make sure that the `python` command invokes the python 3.6 interpreter. EDIT: from what I read on the …

Member Avatar for lewashby
0
683

The End.