Re: Exception

2019-09-24 Thread ast
Le 24/09/2019 à 15:51, אורי a écrit : https://stackoverflow.com/a/24752607/1412564 thank you for link. it's clear now -- https://mail.python.org/mailman/listinfo/python-list

Funny code

2019-09-25 Thread ast
Hello A line of code which produce itself when executed >>> s='s=%r;print(s%%s)';print(s%s) s='s=%r;print(s%%s)';print(s%s) Thats funny ! -- https://mail.python.org/mailman/listinfo/python-list

__init__ is not invoked

2019-09-26 Thread ast
Hello In the following code found here: https://www.pythonsheets.com/notes/python-object.html __init__ is not invoked when we create an object with "o = ClassB("Hello")". I don't understand why. I know the correct way to define __new__ is to write "return object.__new__(cls, arg)" and not "retur

Re: __init__ is not invoked

2019-09-26 Thread ast
Le 26/09/2019 à 14:20, ast a écrit : Hello In the following code found here: https://www.pythonsheets.com/notes/python-object.html __init__ is not invoked when we create an object with "o = ClassB("Hello")". I don't understand why. I know the correct way to define __

Re: __init__ is not invoked

2019-09-26 Thread ast
Le 26/09/2019 à 15:17, Peter Otten a écrit : ast wrote: __init__ is called only if __new__ returns an instance of ClassB: I was ignoring that. thank you -- https://mail.python.org/mailman/listinfo/python-list

Recursive method in class

2019-09-27 Thread ast
Hello Is it feasible to define a recursive method in a class ? (I don't need it, it's just a trial) Here are failing codes: class Test: def fib(self, n): if n < 2: return n return fib(self, n-2) + fib(self, n-1) t = Test() t.fib(6) - Traceback (most r

Re: Recursive method in class

2019-09-30 Thread ast
Le 27/09/2019 à 14:26, Jan van den Broek a écrit : On 2019-09-27, ast wrote: Is it feasible to define a recursive method in a class ? (I don't need it, it's just a trial) Here are failing codes: class Test: def fib(self, n): if n < 2: return n return

Re: Recursive method in class

2019-10-01 Thread ast
Le 30/09/2019 à 13:11, Anders Märak Leffler a écrit : What do you mean by transformed? This is probably your understanding already, but a further consequence of when arguments are evaluated plus what you said about data attributes is that the fib(self, n - 1) call will follow the standard LEGB-lo

"Regular Expression Objects" scanner method

2019-10-01 Thread ast
Hello I am trying to understand a program which use a method named scanner on a re compiled object. This program is named "Simple compiler" here: https://www.pythonsheets.com/notes/python-generator.html But unfortunately it is not documented nor here: https://docs.python.org/3.7/library/re.htm

Re: Recursive method in class

2019-10-01 Thread ast
Le 01/10/2019 à 13:18, Rhodri James a écrit : On 01/10/2019 08:37, ast wrote: The problem is that "factorial" in line "return n * factorial(self, n - 1)" should not have been found because there is no factorial function defined in the current scope. Not so.  "fa

Re: Recursive method in class

2019-10-01 Thread ast
Le 01/10/2019 à 20:56, Timur Tabi a écrit : Could you please fix your email software so that it shows a legitimate email address in the From: line? Your emails all show this: From: ast All of your emails are being caught in my spam filter because of this address. I would email you

Re: Recursive method in class

2019-10-02 Thread ast
Le 02/10/2019 à 12:22, Richard Damon a écrit : On 10/2/19 1:12 AM, ast wrote: Le 01/10/2019 à 20:56, Timur Tabi a écrit : Could you please fix your email software so that it shows a legitimate email address in the From: line?  Your emails all show this: From: ast All of your emails

threading

2019-12-04 Thread ast
Hi An operation like x+=1 on a global variable x is not thread safe because there can be a thread switch between reading and writing to x. The correct way is to use a lock lock = threading.Lock with lock: x+=1 I tried to write a program without the lock which should fail. Here it is: im

Decorator with parameters

2020-04-06 Thread ast
Hello I wrote a decorator to add a cache to functions. I realized that cache dictionnary could be defined as an object attribute or as a local variable in method __call__. Both seems to work properly. Can you see any differences between the two variants ? from collection import OrderedDict clas

Re: Floating point problem

2020-04-17 Thread ast
Le 17/04/2020 à 13:40, Aakash Jana a écrit : I am running python 3.8 only but my issue is I need more zeroes after my result. I want 2/5 = 0.40 But I am only getting 0.4 f"{2/5:.6f}" '0.40' -- https://mail.python.org/mailman/listinfo/python-list

Re: Floating point problem

2020-04-18 Thread ast
Le 18/04/2020 à 15:07, Souvik Dutta a écrit : I have one question here. On using print(f"{c:.32f}") where c= 2/5 instead of getting 32 zeroes I got some random numbers. The exact thing is 0.40002220446049250313 Why do I get this and not 32 zeroes? 2/5 = 0.0110011001100110011001..

Not understood error with __set_name__ in a descriptor class

2020-04-19 Thread ast
Hello This code is working well: (I am using python 3.6.3) class my_property: def __init__(self, fget=None, fset=None, fdel=None): self.fget = fget self.fset = fset self.fdel = fdel def __set_nam

Re: Not understood error with __set_name__ in a descriptor class

2020-04-19 Thread ast
Le 19/04/2020 à 17:06, ast a écrit : I understood where the problem is. Once __get__ is defined, it is used to read self._name in method __set_name__ and it is not défined yet. That's why I have an error "'NoneType' object is not callable" Thats a nice bug. I need

Something annoying about method __set_name__ in descriptors

2020-04-21 Thread ast
Hello From python version 3.6, there is a useful new method __set_name__ which could be implemented in descriptors. This method is called after a descriptor is instantiated in a class. Parameter "name" is filled with the name of the attribute refering to the descriptor in the class Here is an e

Re: Something annoying about method __set_name__ in descriptors

2020-04-21 Thread ast
Le 21/04/2020 à 18:32, Dieter Maurer a écrit : ast wrote at 2020-4-21 14:27 +0200: I recently read the Python (3.9a5) documentation - and there I found clearly expressed this behaviour (I no longer can tell you exactly where I read this). The reason comes from the implementation: when the

matplotlib: Difference between Axes and AxesSubplot

2020-04-27 Thread ast
Hello It's not clear to me what the differences between Axes and AxesSubplot classes are AxesSubplot is a sub class of Axes It is possible to draw in objects of both type with plot, scatter ... Axes object seems to be able to be inserted in AxesSubplot object (It is strange because AxesSubplot

Re: Function to avoid a global variable

2020-04-27 Thread ast
Le 27/04/2020 à 04:46, Bob van der Poel a écrit : Does this make as much sense as anything else? I need to track calls to a function to make sure it doesn't get called to too great a depth. I had a global which I inc/dec and then check in the function. Works fine, but I do need to keep a global a

Re: Function to avoid a global variable

2020-04-28 Thread ast
Le 28/04/2020 à 08:51, ast a écrit : Le 27/04/2020 à 04:46, Bob van der Poel a écrit : Does this make as much sense as anything else? I need to track calls to a function to make sure it doesn't get called to too great a depth. I had a global which I inc/dec and then check in the function.

Re: Function to avoid a global variable

2020-04-28 Thread ast
Le 28/04/2020 à 09:13, Chris Angelico a écrit : On Tue, Apr 28, 2020 at 4:56 PM ast wrote: Le 27/04/2020 à 04:46, Bob van der Poel a écrit : "Best"? Not sure about that. Functions are first-class objects in Python, so a function *is* a callable object. You don't have to

Re: Function to avoid a global variable

2020-04-28 Thread ast
Le 28/04/2020 à 09:52, ast a écrit : Le 28/04/2020 à 09:39, Antoon Pardon a écrit : Op 27/04/20 om 18:39 schreef Bob van der Poel: Thanks Chris! At least my code isn't (quite!) as bad as the xkcd example :) Guess my "concern" is using the initialized array in the function:

Re: Function to avoid a global variable

2020-04-28 Thread ast
Le 28/04/2020 à 09:39, Antoon Pardon a écrit : Op 27/04/20 om 18:39 schreef Bob van der Poel: Thanks Chris! At least my code isn't (quite!) as bad as the xkcd example :) Guess my "concern" is using the initialized array in the function:     def myfunct(a, b, c=array[0,1,2,3] ) always feels

Re: Conway's game of Life, just because.

2020-04-28 Thread ast
Le 07/05/2019 à 05:31, Paul Rubin a écrit : #!/usr/bin/python3 from itertools import chain def adjacents(cell):# generate coordinates of cell neighbors x, y = cell # a cell is just an x,y coordinate pair return ((x+i,y+j) for i in [-1,0,1] for j in [-1,0,1]

Re: JH Conway memorial Life program

2020-04-28 Thread ast
Le 12/04/2020 à 23:40, Paul Rubin a écrit : You might have heard by now that John Horton Conway died yesterday at age 82, of complications from the SARS-Cov2 aka Corona virus. Among his many cool accomplishments was inventing the Game of Life, which was one of my first exercises as a beginning p

Problem with doctest

2020-05-04 Thread ast
Hello doctest of the sample function funct() doesn't works because flag used by funct() is the one defined in first line "flag = True" and not the one in the doctest code ">>> flag = False". Any work around known ? flag = True # <- funct() always use this one def funct(): """

Can a print overwrite a previous print ?

2020-05-08 Thread ast
Hello Suppose we want that: print("abcdef"); print("ghi") produces: ghidef The 2nd print overwrites the first one. Is it feasible ? It should since the progress bar tdqh seems to do that try: from tkdm import tkdm for i in tqdm(range(100_000_000)): pass It produces a progress bar li

property

2020-06-26 Thread ast
Hello, I am wondering why this code is OK: class Temperature: def __init__(self): self.celsius = 0 fahrenheit = property() @fahrenheit.getter def fahrenheit(self): return 9/5*self.celsius +32 @fahrenheit.setter def fahrenheit(self, value

Re: property

2020-06-30 Thread ast
Le 26/06/2020 à 10:16, R.Wieser a écrit : ast, I have absolutily /no idea/ about how that "fahrenheit = property()" comes into play though. It just creates an empty property object. You can then fill this object with the read/write/delete functions with the methods gett

Re: property

2020-06-30 Thread ast
Le 26/06/2020 à 15:12, Peter Otten a écrit : Unknown wrote: The getter/setter of the property builtin return a new property p = property() q = p.getter(None) p is q False where you def getter(self, fget): self.fget = fget return self modify the existing one.

Returning from a multiple stacked call at once

2020-12-11 Thread ast
Hello In case a function recursively calls itself many times, is there a way to return a data immediately without unstacking all functions ? -- https://mail.python.org/mailman/listinfo/python-list

Re: Returning from a multiple stacked call at once

2020-12-12 Thread ast
Le 12/12/2020 à 09:18, Cameron Simpson a écrit : On 12Dec2020 07:39, ast wrote: In case a function recursively calls itself many times, is there a way to return a data immediately without unstacking all functions ? Not really. Do you have an example where this is inconvenient? There are

Re: Returning from a multiple stacked call at once

2020-12-12 Thread ast
Le 12/12/2020 à 17:10, Oscar a écrit : In article <5fd465b5$0$8956$426a7...@news.free.fr>, ast wrote: Hello In case a function recursively calls itself many times, is there a way to return a data immediately without unstacking all functions ? If you are referring to your "

True/False value testing

2016-01-07 Thread ast
Hello For integer, 0 is considered False and any other value True A=0 A==False True A==True False A=1 A==False False A==True True It works fine For string, "" is considered False and any other value True, but it doesn't work A = "" A==False False A==True False A = 'Z' A==False F

class attribute

2016-01-28 Thread ast
hello Here is a class from django framework from django.db import models class Article(models.Model): titre = models.CharField(max_length=100) auteur = models.CharField(max_length=42) contenu = models.TextField(null=True) date = models.DateTimeField(auto_now_add=True, auto_now=Fal

Re: class attribute

2016-01-28 Thread ast
"ast" a écrit dans le message de news:56aa1474$0$27833$426a7...@news.free.fr... OK, thank you for answer I didn't studied metaclass yet that's why it is not clear for me. I have to take a look at that concept first -- https://mail.python.org/mailman/listinfo/python-list

__bases__ attribute on classes not displayed by dir() command

2016-02-04 Thread ast
Hi I have a Carre class which inherit from a Rectangle class. Carre has a __bases__ tuple attribute which contains the classes which it inherit from. Carre.__bases__ (,) and Rectangle only inherit from object, so: Rectangle.__bases__ (,) Thats OK but if I am using dir to display all Carr

Finding in which class an object's method comes from

2016-02-04 Thread ast
Hi Suppose we have: ClassC inherit from ClassB ClassB inherit from ClassA ClassA inherit from object Let's build an object: obj = ClassC() Let's invoke an obj method obj.funct() funct is first looked in ClassC, then if not found on ClassB, then ClassA then object But is there a command to

Re: Finding in which class an object's method comes from

2016-02-04 Thread ast
"Chris Angelico" a écrit dans le message de news:mailman.43.1454574987.30993.python-l...@python.org... Is that what you're hoping for? yes, ty -- https://mail.python.org/mailman/listinfo/python-list

Re: Finding in which class an object's method comes from

2016-02-04 Thread ast
"Chris Angelico" a écrit dans le message de news:mailman.43.1454574987.30993.python-l...@python.org... You can see that by looking at the objects without calling them: class A: ... def a(self): pass ... class B(A): ... def b(self): pass ... class C(B): ... def c(self): pass ... ob

Re: Finding in which class an object's method comes from

2016-02-04 Thread ast
"Ben Finney" a écrit dans le message de news:mailman.48.1454575803.30993.python-l...@python.org... That's been answered, but I'm curious to know what your program will do with that information? Nothings, I was just wondering. -- https://mail.python.org/mailman/listinfo/python-list

Re: __bases__ attribute on classes not displayed by dir() command

2016-02-04 Thread ast
"eryk sun" a écrit dans le message de news:mailman.49.1454576255.30993.python-l...@python.org... On Thu, Feb 4, 2016 at 2:03 AM, ast wrote: but if I am using dir to display all Carre's attributes and methods, __bases__ is not on the list. Why ? The __bases__ property is

metaclass

2016-02-04 Thread ast
Hi I am looking the relationship between some classes from the enum module from enum import EnumMeta, Enum class Color(Enum): pass type(EnumMeta) EnumMeta.__bases__ (,) so EnumMeta is a metaclass, it is an instance of type and inherit from type too. type(Enum) En

How to define what a class is ?

2016-02-24 Thread ast
Hi Since a class is an object, I ask myself how to define rigorously what a class is. classes are instances from type, but not all, since a class may be an instance of a metaclass A class is always callable A class inherit from some others classes, so they have a bases attribute any thing e

Re: How to define what a class is ?

2016-02-25 Thread ast
"Ian Kelly" a écrit dans le message de news:mailman.85.1456303651.20994.python-l...@python.org... On Wed, Feb 24, 2016 at 1:08 AM, ast wrote: All metaclasses are subclasses of type, so all classes are instances of type. Ah ! I didn't know that if an object Obj is an inst

Dynamic object attribute creation

2016-02-29 Thread ast
Hello Object's attributes can be created dynamically, ie class MyClass: pass obj = MyClass() obj.test = 'foo' but why doesn't it work with built-in classes int, float, list ? L = [1, 8, 0] L.test = 'its a list !' (however lists are mutable, int, float ... are not) Traceback (most rec

What arguments are passed to the __new__ method ?

2016-03-01 Thread ast
Hello It's not clear to me what arguments are passed to the __new__ method. Here is a piece of code: class Premiere: def __new__(cls, price): return object.__new__(cls) def __init__(self, price): pass p = Premiere(1000) No errors, so it seems that 2 arguments are pa

Re: What arguments are passed to the __new__ method ?

2016-03-02 Thread ast
"ast" a écrit dans le message de news:56d5d043$0$632$426a7...@news.free.fr... ty for the détailed explanations. An other question: What is the very first method launched when an instantiation is done ? e.g obj = MyClass(0, 5, 'xyz') is it __call__ (from object or

Re: Explaining names vs variables in Python

2016-03-02 Thread ast
"Salvatore DI DIO" a écrit dans le message de news:a894d5ed-d906-4ff7-a537-32bf0187e...@googlegroups.com... It is a little difficult to explain this behavior to a newcommer in Python Can someone give me the right argument to expose ? It is explained with many details here: http://blog.ler

A mistake which almost went me mad

2016-03-03 Thread ast
Hello This has to be told I created a file pickle.py in order to test some files read/write with objects and put it in a directory which is on my python path. Then the nightmare began - Idle no longer works, window no longer opens when double clicked, no errors messsages - python -m pip l

Tiny python code I dont understand

2016-03-08 Thread ast
Hello lst = [(1,2,3), (4, 5,6)] sum(lst, ()) (1, 2, 3, 4, 5, 6) Any explanations ? thx -- https://mail.python.org/mailman/listinfo/python-list

Re: Tiny python code I dont understand

2016-03-08 Thread ast
"Jussi Piitulainen" a écrit dans le message de news:lf58u1t53sb@ling.helsinki.fi... ast writes: Hello lst = [(1,2,3), (4, 5,6)] sum(lst, ()) (1, 2, 3, 4, 5, 6) Any explanations ? (() + (1,2,3)) + (4,5,6) yes, ty -- https://mail.python.org/mailman/listinfo/python-list

Re: Tiny python code I dont understand

2016-03-08 Thread ast
"ast" a écrit dans le message de news:56defc8e$0$3341$426a7...@news.free.fr... Hello lst = [(1,2,3), (4, 5,6)] sum(lst, ()) (1, 2, 3, 4, 5, 6) Any explanations ? thx OK, sorry, I finally understand. This is because adding tuple (or list or string ...) is a concatenation (

Python path

2016-03-08 Thread ast
Hello Python path may be read with: import sys sys.path There is an environnement variable $PYTHONPATH (windows) to set if you want to add some additionnal directories to the path. But the default path seems not to be stored in any environnement variable. Is it correct ? Is it stored somewhe

Re: submodules

2016-03-18 Thread ast
"Peter Otten" <__pete...@web.de> a écrit dans le message de news:mailman.312.1458299016.12893.python-l...@python.org... ast wrote: ok, thx -- https://mail.python.org/mailman/listinfo/python-list

submodules

2016-03-19 Thread ast
Hello Since in python3 ttk is a submodule of tkinter, I was expecting this to work: from tkinter import * root = Tk() nb = ttk.Notebook(root) but it doesnt, ttk is not known. I have to explicitely import ttk with from tkinter import ttk why ? -- https://mail.python.org/mailman/listinfo/pyth

newbie question

2016-03-24 Thread ast
Hi I have a string which contains a tupe, eg: s = "(1, 2, 3, 4)" and I want to recover the tuple in a variable t t = (1, 2, 3, 4) how would you do ? -- https://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2016-03-24 Thread ast
"David Palao" a écrit dans le message de news:mailman.86.1458816553.2244.python-l...@python.org... Hi, Use "eval": s = "(1, 2, 3, 4)" t = eval(s) Best Thank you -- https://mail.python.org/mailman/listinfo/python-list

Path when reading an external file

2016-03-28 Thread ast
Hello In a program "code.py" I read an external file "foo.txt" supposed to be located in the same directory that "code.py" python/src/code.py python/src/foo.txt In "code.py": f = open('foo.txt', 'r') But if I run "python code.py" in an other dir than src/ say in python/, it will not work bec

Re: newbie question

2016-03-28 Thread ast
"Matt Wheeler" a écrit dans le message de news:mailman.92.1458825746.2244.python-l...@python.org... On Thu, 24 Mar 2016 11:10 Sven R. Kunze, wrote: On 24.03.2016 11:57, Matt Wheeler wrote: >>>> import ast >>>> s = "(1, 2, 3, 4)" >>>>

Re: Path when reading an external file

2016-03-28 Thread ast
"Martin A. Brown" a écrit dans le message de news:mailman.108.1459179618.28225.python-l...@python.org... Greetings, In a program "code.py" I read an external file "foo.txt" supposed to be located in the same directory that "code.py" python/src/code.py python/src/foo.txt In "code.py": f =

Re: (test) ? a:b

2014-10-23 Thread ast
48K? Luxury! ZX81 had an option for 64K -- https://mail.python.org/mailman/listinfo/python-list

Re: (test) ? a:b

2014-10-27 Thread ast
"Mark Lawrence" a écrit dans le message de news:mailman.15070.1413978605.18130.python-l...@python.org... Also would you please access this list via https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seein

Callback functions arguments

2014-10-27 Thread ast
Hi In this web site at example n°5 http://fsincere.free.fr/isn/python/cours_python_tkinter.php A program is using the "Scale" widget from tkinter module. Here is a piece of code: Valeur = StringVar() echelle = Scale(Mafenetre, from_=-100, to=100, resolution=10, \ orient=HORIZONTAL, length=300,

Re: Callback functions arguments

2014-10-28 Thread ast
"Peter Otten" <__pete...@web.de> a écrit dans le message de news:mailman.15231.1414399974.18130.python-l...@python.org... Tanks for you answer Python doesn't "know" it has to pass an argument, it just does it. Change the callback to def maj(): print("no args") and you'll get an error.

Re: Callback functions arguments

2014-10-28 Thread ast
"Chris Angelico" a écrit dans le message de news:mailman.15254.1414482690.18130.python-l...@python.org... On Tue, Oct 28, 2014 at 6:35 PM, ast wrote: That's clear to me now. Spinbox and Scale widgets behave differently, that's all. Command on Scale widget: A procedur

Meaning of * in the function arguments list

2014-10-29 Thread ast
Hi Consider the following to_bytes method from integer class: int.to_bytes(length, byteorder, *, signed=False) What doest the '*' in the arguments list means ? -- https://mail.python.org/mailman/listinfo/python-list

Re: Meaning of * in the function arguments list

2014-10-29 Thread ast
"Peter Otten" <__pete...@web.de> a écrit dans le message de news:mailman.15291.1414574006.18130.python-l...@python.org... A bare * indicates that the arguments that follow it are keyword-only: ok, thx -- https://mail.python.org/mailman/listinfo/python-list

Has color "Green" changed from Python 33 to 34 ?

2014-10-30 Thread ast
Hi I just updated this morning my Python from a 3.3rc to 3.4 (Windows) and I noticed that the 'Green' color in tkinter GUI is not the same at all. 'Green' in 3.4 is very dark. I had to replace it with 'Lime' to get back a nice 'Green'. -- https://mail.python.org/mailman/listinfo/python-list

Re: Classes

2014-10-31 Thread ast
"Seymore4Head" a écrit dans le message de news:51755at03r0bidjqh3qf0hhpvjr8756...@4ax.com... class pet: def set_age(self,age): self.age=age def get_age(self): return self.age pax=pet pax.set_age(4) Traceback (most recent call last): File "C:\Functions\test.py", line 18, i

Re: Classes

2014-10-31 Thread ast
"ast" a écrit dans le message de news:545350c3$0$23449$426a7...@news.free.fr... I am a beginner too, but I find it strange that your pet class has no __init__ method to construct instances It works anyway because __init__ is taken in the parent Class, probably Object. But this

Re: Classes

2014-10-31 Thread ast
"Seymore4Head" a écrit dans le message de news:rbf75ah9l1jp9e72gqr0ncu7bau8cnt...@4ax.com... What material have you used to take you up to classes? It's a french classroom on the web http://openclassrooms.com/courses/apprenez-a-programmer-en-python -- https://mail.python.org/mailman/lis

fill, expand from tkinter.pack() layout manager

2014-11-04 Thread ast
Hi I dont really understood how "fill" and "expand" works with layout manager tkinter.pack() Example: from tkinter import * root = Tk() w = Label(root, text="Red", bg="red", fg="white") w.pack(side=LEFT, fill = BOTH) Here is the result: http://cjoint.com/?0Kepj1E3Tv3 Why is the label "w" onl

Re: fill, expand from tkinter.pack() layout manager

2014-11-04 Thread ast
"ast" a écrit dans le message de news:5458dfc6$0$27505$426a7...@news.free.fr... w.pack(side=LEFT, fill = BOTH) Why is the label "w" only extended vertically and not horizontally too ? with: w.pack(side=TOP, fill = BOTH) it expand horizontally but not vertically wi

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread ast
a écrit dans le message de news:e5c95792-f81f-42b4-9996-5545f5607...@googlegroups.com... On Tuesday, November 4, 2014 8:49:36 AM UTC-8, françai s wrote: I can't think of any reason why someone would WANT to program in binary/hex machine code. It happens if you design yourself a specialize

Moving a window on the screen

2014-11-06 Thread ast
Hi Why the following program doesn't work ? for x in range(0, 100, 10): fen.geometry("200x200+%d+10" % x) time.sleep(0.5) where fen is a window (fen = Tk()) The fen window goes from it's initial location to the last one but we dont see all the intermediate steps thx -- https://m

Re: Moving a window on the screen

2014-11-06 Thread ast
"Chris Angelico" a écrit dans le message de news:mailman.15536.1415264262.18130.python-l...@python.org... You usually don't want to use time.sleep() in a GUI program. Try doing the same thing, but with an event loop delay call instead; often, the display won't update until you go back to the

Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread ast
"Robert Voigtländer" a écrit dans le message de news:e5c93b46-a32b-4eca-a00d-f7dd2b4bb...@googlegroups.com... 1011 What I mean is do you throw away the carry or does each row have only one zero? Not sure what you mean. Each row must have one 1. The rest must be 0. No combinations not fitting

Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread ast
"Robert Voigtländer" a écrit dans le message de news:0e6787f9-88d6-423a-8410-7578fa83d...@googlegroups.com... Let be L the number of lines and C the numbers of column You solve your problem just with counting on base C On base C, a number may be represented with N(L-1)N(L-2) ... N(0)N(0) w

Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread ast
"ast" a écrit dans le message de news:545cf9f0$0$2913$426a3...@news.free.fr... On base C, a number may be represented with N(L-1)N(L-2) ... N(1)N(0) where N(i) goes from 0 to C-1 -- https://mail.python.org/mailman/listinfo/python-list

Curious function argument

2014-11-12 Thread ast
Hello I saw in a code from a previous message in this forum a curious function argument. def test(x=[0]): print(x[0]) ## Poor man's object x[0] += 1 test() 0 test() 1 test() 2 I understand that the author wants to implement a global variable x . It would be better to write 'glob

Synchronizing a sound with a widget change

2014-11-13 Thread ast
Hello, here is a small test code: from tkinter import Tk, Frame from winsound import Beep root = Tk() f = Frame(root, width=300, height=300) f.pack() f.config(bg='Yellow') Beep(2000, 1000) -- I intended to change the frame color to yellow (f.config(bg='Yellow')) a

Re: Synchronizing a sound with a widget change

2014-11-13 Thread ast
"ast" a écrit dans le message de news:54648d03$0$1981$426a7...@news.free.fr... I have the idea to run an other thread to emit the sound, but I didn't try yet. Is it the solution ? nope, still doesn't work ! --- from tkinter i

Re: Synchronizing a sound with a widget change

2014-11-13 Thread ast
"ast" a écrit dans le message de news:54648e75$0$12771$426a7...@news.free.fr... "ast" a écrit dans le message de news:54648d03$0$1981$426a7...@news.free.fr... I have the idea to run an other thread to emit the sound, but I didn't try yet. Is it the solution

Re: Synchronizing a sound with a widget change

2014-11-13 Thread ast
"Dave Angel" a écrit dans le message de news:mailman.15773.1415878987.18130.python-l...@python.org... I don't use Windows, but from what I read, winsound.Beep is a blocking call, and therefore must not be used in the main thread of a gui environment. Once the function is called, no events

Two locations for module struct ?

2014-11-14 Thread ast
Hello In module wave there is a sub module struct. You can call function pack() with: import wave val = wave.struct.pack(...) but the same function can be called with: import struct val = struct.pack(...) Is it exactly the same module in both location ? Why putting struct in two places ?

Re: Two locations for module struct ?

2014-11-14 Thread ast
"Peter Otten" <__pete...@web.de> a écrit dans le message de news:mailman.15823.1415983912.18130.python-l...@python.org... Do you see the pattern? You should ;) Understood thx -- https://mail.python.org/mailman/listinfo/python-list

Strange result with timeit execution time measurment

2014-11-15 Thread ast
Hi I needed a function f(x) which looks like sinus(2pi.x) but faster. I wrote this one: -- from math import floor def sinusLite(x): x = x - floor(x) return -16*(x-0.25)**2 + 1 if x < 0.5 else 16*(x-0.75)**2 - 1 -- then i used module timeit

I dont understand root['bg'] = 'red' where root is a tkinter.Tk object

2014-11-17 Thread ast
Hello, import tkinter root = tkinter.Tk() Let's see all attributes of root: root.__dict__ {'master': None, 'children': {}, '_tclCommands': ['tkerror', 'exit', '13825848destroy'], 'tk': , '_tkloaded': 1} Now we change the background color using following command: root['bg'] = 'red' I am w

Re: I dont understand root['bg'] = 'red' where root is a tkinter.Tk object

2014-11-17 Thread ast
"Peter Otten" <__pete...@web.de> a écrit dans le message de news:mailman.15958.1416233676.18130.python-l...@python.org... ty -- https://mail.python.org/mailman/listinfo/python-list

tkinter mainloop

2014-11-19 Thread ast
Hello mainloop() is a window method which starts the event manager which tracks for events (mouse, keyboard ...) to be send to the window. But if I forget the root.mainloop() in my program, it works well anyway, I cant see any failure. Why ? Second question, is it possible to cancel a main

Re: tkinter mainloop

2014-11-20 Thread ast
"Rick Johnson" a écrit dans le message de news:3385be62-e21c-4efe-802e-8f7351155...@googlegroups.com... You don't need to call "mainloop()" when building Tkinter widgets on the command-line, but for *real* scripts i believe you'll need to. For instance, if you run the following code you wil

tabs with tkinter

2014-11-28 Thread ast
Hi I have been using tkinter for few weeks now and I didn't found how to make some tabs on a window. see this picture for a window with tabs http://www.computerhope.com/jargon/t/tabs.gif Isn't it feasible with tkinter ? thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread ast
Hi Here is a solution with a custom iterator which operate on files. I tested it with a small file. Just a remark, there are no empty line on a file, there is at least '\n' at the end of each lines but maybe the last one. If readline() got an emptyline, then the end of file has been reached.

Re: tabs with tkinter

2014-11-28 Thread ast
"Peter Otten" <__pete...@web.de> a écrit dans le message de news:mailman.16409.1417189956.18130.python-l...@python.org... See thx -- https://mail.python.org/mailman/listinfo/python-list

time.monotonic() roll over

2014-12-04 Thread ast
Hello, Does any body know when time.monotonic() rolls over ? On python doc https://docs.python.org/3/library/time.html it is said every 49.7 days on Windows versions older than Vista. For more recent Windows, it is sais that monotonic() is system-wide but they dont say anything about roll ov

How to detect that a function argument is the default one

2014-12-10 Thread ast
Hello Here is what I would like to implement class Circle: def __init__(center=(0,0), radius=10, mass=1)): self.center = center self.radius = radius if "mass is the default one": <- self.mass = radius**2 else: self.mass = mass I

<    1   2   3   >