Strange behavior with sort()

2014-02-26 Thread ast
Hello box is a list of 3 integer items If I write: box.sort() if box == [1, 2, 3]: the program works as expected. But if I write: if box.sort() == [1, 2, 3]: it doesn't work, the test always fails. Why ? Thx -- https://mail.python.org/mailman/listinfo/python-list

Re: Strange behavior with sort()

2014-02-26 Thread ast
Thanks for the very clear explanation -- https://mail.python.org/mailman/listinfo/python-list

Reference

2014-03-03 Thread ast
hello Consider following code: A=7 B=7 A is B True I understand that there is a single object 7 somewhere in memory and both variables A and B point toward this object 7 now do the same with a list: l1 = [1, 2] l2 = [1, 2] l1 is l2 False It seems this time that there are 2 distincts

Re: Object identity (was: Reference)

2014-03-03 Thread ast
thanks ben, that's clear -- https://mail.python.org/mailman/listinfo/python-list

Changer le path pour l'accès aux modules

2014-09-12 Thread ast
bonjour Mon path est: sys.path [' ', 'C:\\Python33\\Lib\\idlelib', 'C:\\Windows\\system32\\python33.zip', 'C:\\Python33\\DLLs', 'C:\\Python33\\lib', 'C:\\Python33', 'C:\\Python33\\lib\\site-packages', 'mypath'] Tout d'abord à quoi correspond le ' ' vide au tout début ? Pourquoi y a t'il deux

Re: Changer le path pour l'accès aux modules

2014-09-12 Thread ast
ast nom...@invalid.com a écrit dans le message de news:5412f2cb$0$2069$426a3...@news.free.fr... bonjour Mon path est: sys.path [' ', 'C:\\Python33\\Lib\\idlelib', 'C:\\Windows\\system32\\python33.zip', 'C:\\Python33\\DLLs', 'C:\\Python33\\lib', 'C:\\Python33', 'C:\\Python33\\lib\\site

brackets at the end of a method name

2014-09-24 Thread ast
Hi Once a file is opened with: f=open(foo.txt, r) we have some methods associated with file f f.read() f.readline() .. f.close() f.name f.mode I dont understand why sometimes there are brackets () at the end of the method name (ie close())and sometimes no (ie name) I thought that maybe

Re: brackets at the end of a method name

2014-09-24 Thread ast
Andrea D'Amore anddamnopsam+gru...@brapi.net a écrit dans le message de news:lvuhdu$c6q$1...@virtdiesel.mng.cu.mi.it... On 2014-09-24 13:30:55 +, ast said: we have some methods associated with file f […] f.close() f.name print(type(f.close)) print(type(f.name)) Spot the difference

(test) ? a:b

2014-10-22 Thread ast
Hello Is there in Python something like: j = (j = 10) ? 3 : j+1; as in C language ? thx -- https://mail.python.org/mailman/listinfo/python-list

(-1)**1000

2014-10-22 Thread ast
Hello If i am writing (-1)**1000 on a python program, will the interpreter do (-1)*(-1)*...*(-1) or something clever ? In fact i have (-1)**N with N an integer potentially big. I do some tests that suggest that Python is clever thx -- https://mail.python.org/mailman/listinfo/python-list

Re: (test) ? a:b

2014-10-22 Thread ast
busca...@gmail.com a écrit dans le message de news:7839376e-fc27-4299-ae63-4ddf17ef9...@googlegroups.com... Em quarta-feira, 22 de outubro de 2014 06h29min55s UTC-2, ast escreveu: Hello Is there in Python something like: j = (j = 10) ? 3 : j+1; as in C language ? thx without

Re: (-1)**1000

2014-10-22 Thread ast
Chris Angelico ros...@gmail.com a écrit dans le message de news:mailman.15058.1413968065.18130.python-l...@python.org... On Wed, Oct 22, 2014 at 7:27 PM, ast nom...@invalid.com wrote: If i am writing (-1)**1000 on a python program, will the interpreter do (-1)*(-1)*...*(-1) or something

Re: (test) ? a:b

2014-10-24 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 breamore...@yahoo.co.uk 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

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. If I

Re: Callback functions arguments

2014-10-28 Thread ast
Chris Angelico ros...@gmail.com 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 nom...@invalid.com wrote: That's clear to me now. Spinbox and Scale widgets behave differently, that's all. Command on Scale widget

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 Seymore4Head@Hotmail.invalid 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

Re: Classes

2014-10-31 Thread ast
ast nom...@invalid.com 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

Re: Classes

2014-10-31 Thread ast
Seymore4Head Seymore4Head@Hotmail.invalid 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 --

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 only extended

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

2014-11-04 Thread ast
ast nom...@invalid.com 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 with: w.pack

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
sohcahto...@gmail.com 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

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 --

Re: Moving a window on the screen

2014-11-06 Thread ast
Chris Angelico ros...@gmail.com 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

Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread ast
Robert Voigtländer r.voigtlaen...@gmail.com 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

Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread ast
Robert Voigtländer r.voigtlaen...@gmail.com 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

Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread ast
ast nom...@invalid.com 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

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'))

Re: Synchronizing a sound with a widget change

2014-11-13 Thread ast
ast nom...@invalid.com 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 import

Re: Synchronizing a sound with a widget change

2014-11-13 Thread ast
ast nom...@invalid.com a écrit dans le message de news:54648e75$0$12771$426a7...@news.free.fr... ast nom...@invalid.com 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

Re: Synchronizing a sound with a widget change

2014-11-13 Thread ast
Dave Angel da...@davea.name 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

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': tkapp object at 0x02949C28, '_tkloaded': 1} Now we change the background color using following command:

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

Re: tkinter mainloop

2014-11-20 Thread ast
Rick Johnson rantingrickjohn...@gmail.com 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

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 http://www.tkdocs.com/tutorial/complex.html#notebook 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

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

Re: How to detect that a function argument is the default one

2014-12-10 Thread ast
Skip Montanaro skip.montan...@gmail.com a écrit dans le message de news:mailman.16809.1418225382.18130.python-l...@python.org... On Wed, Dec 10, 2014 at 9:14 AM, ast nom...@invalid.com wrote: thx -- https://mail.python.org/mailman/listinfo/python-list

Re: How to detect that a function argument is the default one

2014-12-10 Thread ast
Chris Angelico ros...@gmail.com a écrit dans le message de news:mailman.16814.1418228205.18130.python-l...@python.org... On Thu, Dec 11, 2014 at 3:10 AM, Jean-Michel Pichavant jeanmic...@sequans.com wrote: - Original Message - From: ast nom...@invalid.com But there's an issue

Problem with a dialog

2014-12-11 Thread ast
Hello I provide two almost identical small test case programs. The first one works as expected, 'True' is printed on the console. With the second one Python complains that 'test' is not known. I dont understand why. Python 3.4, windows # ## First #

Re: Problem with a dialog

2014-12-11 Thread ast
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info a écrit dans le message de news:54898820$0$12989$c3e8da3$54964...@news.astraweb.com... As I said, most programming languages work like this. But a small minority use a different system, called dynamic scoping. In dynamic scoping, it

Re: Problem with a dialog

2014-12-11 Thread ast
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info a écrit dans le message de news:54898820$0$12989$c3e8da3$54964...@news.astraweb.com... You can make test global by declaring it global: def try_(): global test test = True setup = MyDialog(root) If that solves your problem to

meaning of: line, =

2015-02-04 Thread ast
hello I dont understand why there is a comma just after line in the following command: line, = plt.plot(x, np.sin(x), '--', linewidth=2) I never saw that before Found here: http://matplotlib.org/examples/lines_bars_and_markers/line_demo_dash_control.html thanks --

Re: meaning of: line, =

2015-02-05 Thread ast
ast nom...@invalid.com a écrit dans le message de news:54d227ef$0$3292$426a7...@news.free.fr... thanks for the answers -- https://mail.python.org/mailman/listinfo/python-list

A question about how plot from matplotlib works

2015-02-19 Thread ast
Hello import numpy as np import matplotlib.pyplot as plt x = np.arange(10) y = x**2 x array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) y array([ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81]) plt.plot(x,y) [matplotlib.lines.Line2D object at 0x044F5930] plt.show() The question is: plt.plot() creates an

Re: Bad text appearance in IDLE

2015-02-20 Thread ast
David H. Lipman DLipman~nospam~@Verizon.Net a écrit dans le message de news:czgdnvx2faf0q0ljnz2dnuu7-uwdn...@giganews.com... http://support.microsoft.com/kb/3013455 KB3013455 has been found to be causing Display Font problems for Windows Vista and Server 2003. A partial mitigation is to

matplotlib.pyplot documentation

2015-02-19 Thread ast
hello I got this module documentation with help(matplotlib.pyplot) for each function there is a demo file, for example: barbs(*args, **kw) Plot a 2-D field of barbs. **Example:** .. plot:: mpl_examples/pylab_examples/barb_demo.py but I dont find the

Re: Bad text appearance in IDLE

2015-02-13 Thread ast
Frank Millman fr...@chagford.com a écrit dans le message de news:mailman.18720.1423801380.18130.python-l...@python.org... I use Windows Server 2003. It also ran an automatic update yesterday. Something seems to have gone wrong with the system font. I don't use IDLE, but I use OutlookExpress

Re: Bad text appearance in IDLE

2015-02-13 Thread ast
Terry Reedy tjre...@udel.edu a écrit dans le message de news:mailman.18714.1423775571.18130.python-l...@python.org... Do you get anything similar when running the console interpreter? yes import tkinter as tk root = tk.Tk() text = tk.Text() text.pack() text.insert('1.0', 'this is a test

Bad text appearance in IDLE

2015-02-12 Thread ast
Hello Here is how text appears in IDLE window http://www.cjoint.com/data/0BmnEIcxVAx.htm Yesterday evening I had not this trouble. It appears this morning. I restarted my computer with no effect. A windows Vista update has been done this morning, with about 10 fixes. I suspect something gone

list storing variables

2015-02-23 Thread ast
hi a = 2; b = 5 Li = [a, b] Li [2, 5] a=3 Li [2, 5] Ok, a change in a or b doesn't impact Li. This works as expected Is there a way to define a container object able to store some variables so that a change of a variable make a change in this object content ? I dont need this

Re: for...else

2015-06-02 Thread ast
Laura Creighton l...@openend.se a écrit dans le message de news:mailman.64.1433255400.13271.python-l...@python.org... You may be looking for dictionary dispatching. You can translate the key into a callable. def do_ping(self, arg): return 'Ping, {0}!'.format(arg) def do_pong(self, arg):

Re: Could you explain lambda function to me?

2015-06-02 Thread ast
fl rxjw...@gmail.com a écrit dans le message de news:323866d1-b117-4785-ae24-7d04c49bc...@googlegroups.com... Hi, def make_incrementor(n): ... return lambda x: x + n ... f = make_incrementor(42) f(0) 42 f(1) 43 make_incrementor is a fonction which return a function ! and the

Re: [a,b,c,d] = 1,2,3,4

2015-08-25 Thread ast
Joel Goldstick joel.goldst...@gmail.com a écrit dans le message de news:mailman.23.1440513059.11709.python-l...@python.org... On Tue, Aug 25, 2015 at 10:16 AM, ast nom...@invalid.com wrote: [a,b,c,d] = 1,2,3,4 a 1 b 2 c 3 d 4 I have never seen this syntax before

Re: [a,b,c,d] = 1,2,3,4

2015-08-25 Thread ast
ast nom...@invalid.com a écrit dans le message de news:55dc853c$0$3083$426a7...@news.free.fr... Joel Goldstick joel.goldst...@gmail.com a écrit dans le message de news:mailman.23.1440513059.11709.python-l...@python.org... On Tue, Aug 25, 2015 at 10:16 AM, ast nom...@invalid.com wrote: [a,b

Re: [a,b,c,d] = 1,2,3,4

2015-08-25 Thread ast
Joel Goldstick joel.goldst...@gmail.com a écrit dans le message de news:mailman.27.1440515128.11709.python-l...@python.org... On Tue, Aug 25, 2015 at 10:32 AM, Cody Piersall cody.piers...@gmail.com wrote: On Tue, Aug 25, 2015 at 9:16 AM, ast nom...@invalid.com wrote: The original

[a,b,c,d] = 1,2,3,4

2015-08-25 Thread ast
[a,b,c,d] = 1,2,3,4 a 1 b 2 c 3 d 4 I have never seen this syntax before. Is it documented. Is there a name for that ? thx -- https://mail.python.org/mailman/listinfo/python-list

pygame basic question

2015-09-08 Thread ast
Hi DISPLAYSURF = pygame.display.set_mode((400, 300)) pygame.display.set_caption('Hello World!') The first line opens a 400x300 pygame window. The second one writes "Hello World" on top of it. I am just wondering how function set_caption finds the windows since the window's name DISPLAYSURF

Strange location for a comma

2015-09-03 Thread ast
Hello, At the end of the last line of the following program, there is a comma, I dont understand why ? Thx from cx_Freeze import setup, Executable # On appelle la fonction setup setup( name = "salut", version = "0.1", description = "Ce programme vous dit bonjour", executables =

Re: Strange location for a comma

2015-09-03 Thread ast
"ast" <nom...@invalid.com> a écrit dans le message de news:55e83afb$0$3157$426a7...@news.free.fr... Hello, At the end of the last line of the following program, there is a comma, I dont understand why ? Thx from cx_Freeze import setup, Executable # On appelle la fonc

Re: Strange location for a comma

2015-09-03 Thread ast
"ast" <nom...@invalid.com> a écrit dans le message de news:55e83afb$0$3157$426a7...@news.free.fr... Hello, At the end of the last line of the following program, there is a comma, I dont understand why ? Thx from cx_Freeze import setup, Executable # On appelle la fonc

Re: Need Help w. PIP!

2015-09-04 Thread ast
"Steve Burrus" a écrit dans le message de news:f0876c48-010e-4bf0-b687-dceefba97...@googlegroups.com... Well I hjave certainly noted more than once that pip is cont ained in Python 3.4. But I am having the most extreme problems with simply typing "pip" into my command

Re: Need Help w. PIP!

2015-09-04 Thread ast
"ast" <nom...@invalid.com> a écrit dans le message de news:55e9372e$0$3019$426a3...@news.free.fr... "Steve Burrus" <steveburru...@gmail.com> a écrit dans le message de news:f0876c48-010e-4bf0-b687-dceefba97...@googlegroups.com... Well I hjave certainly noted

Putting the main program in a main function

2015-09-14 Thread ast
Hi I saw here http://inventwithpython.com/pygame/chapter3.html a program where the main program is put in a function. So the structure is: def main(): main code here def f1(): function 1 code def f2(): function 2 code .. if __name__ == '__main__': main() The author says

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

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)

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

2016-02-04 Thread ast
"eryk sun" <eryk...@gmail.com> 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 <nom...@invalid.com> wrote: but if I am using dir to display all Carre's attributes and methods, __bases__ i

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,

__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

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

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. --

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: class attribute

2016-01-28 Thread ast
"ast" <nom...@invalid.com> 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

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

Re: How to define what a class is ?

2016-02-25 Thread ast
"Ian Kelly" <ian.g.ke...@gmail.com> 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 <nom...@invalid.com> wrote: All metaclasses are subclasses of type, so all classes are instances of type

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

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

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

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 ? --

Re: Checking function's parameters (type, value) or not ?

2016-04-06 Thread ast
"Chris Angelico" <ros...@gmail.com> a écrit dans le message de news:mailman.13.1459955565.1197.python-l...@python.org... On Thu, Apr 7, 2016 at 12:18 AM, ast <nomail@com.invalid> wrote: "Mark Lawrence" <breamore...@yahoo.co.uk> a écrit dans le messag

Checking function's parameters (type, value) or not ?

2016-04-06 Thread ast
Hello I would like to know if it is advised or not to test a function's parameters before running it, e.g for functions stored on a public library ? Example: def to_base(nber, base=16, use_af=True, sep=''): assert isinstance(nber, int) and nber >= 0 assert isinstance(base, int) and base

Re: Checking function's parameters (type, value) or not ?

2016-04-06 Thread ast
"Mark Lawrence" <breamore...@yahoo.co.uk> a écrit dans le message de news:mailman.131.1459949361.32530.python-l...@python.org... On 06/04/2016 14:07, ast wrote: Please see http://ftp.dev411.com/t/python/python-list/13bhcknhan/when-to-use-assert Thanks for this paper

Re: Label behavior's difference between tkinter and ttk

2016-04-05 Thread ast
"Kevin Walzer" a écrit dans le message de news:ne1qin$7po$1...@dont-email.me... In general, the "img.config" syntax is suitable for the classic Tk widgets, not the themed ttk widgets. They have a very different (and very gnarly) syntax for indicating changed state. I am

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

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

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" <jussi.piitulai...@helsinki.fi> 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:/

Re: Tiny python code I dont understand

2016-03-08 Thread ast
"ast" <nom...@invalid.com> 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 (o

  1   2   3   >