Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: intering int number
Post: intering int number
hi
in the below code:
#from: https://realpython.com/python-assignment-operator/
''' to detemine intering range for integers'''
from platform import python_version
interning = [
x
for x, y in... |
|
akbarza |
General Coding Help |
1 |
279 |
Apr-28-2024, 07:42 AM |
|
|
Thread: negative memory usage
Post: negative memory usage
hi
in the below code, after running, the usage of memory is shown as a negative number! why?
#from:https://blog.faradars.org/reduce-memory-usage-and-make-your-python-code-faster-using-generators/
'''g... |
|
akbarza |
General Coding Help |
1 |
260 |
Apr-27-2024, 07:41 AM |
|
|
Thread: using mutable in function defintion as optional paramter
Post: RE: using mutable in function defintion as optiona...
hi snppsat
thanks for reply
i read the mentioned page all, but i asked why after production(or creation) the clothes_shop_list dictionary in line 39, the dictionary changes when line 40 is runed and ... |
|
akbarza |
General Coding Help |
8 |
576 |
Apr-26-2024, 08:16 AM |
|
|
Thread: using mutable in function defintion as optional paramter
Post: using mutable in function defintion as optional pa...
hi
I read some about using mutable(list or dict) in function definition as an optional parameter as this was discussed in the site realpython(its address is in the below code). also, I talked about th... |
|
akbarza |
General Coding Help |
8 |
576 |
Apr-25-2024, 08:26 AM |
|
|
Thread: yield from
Post: yield from
hi
in the below code, what is doing yield from? please explain:
#yield_from.py
# from:https://treyhunner.com/2018/04/keyword-arguments-in-python/
def join(*iterables, joiner):
if not iterables:... |
|
akbarza |
General Coding Help |
4 |
431 |
Apr-19-2024, 07:55 AM |
|
|
Thread: questions about dict.get
Post: questions about dict.get
hi
in the below code:
#dict_get.py
print(help(dict.get))
'''
Help on method_descriptor:
get(self, key, default=None, /)
Return the value for key if key is in the dictionary, else default.
'''
d... |
|
akbarza |
General Coding Help |
2 |
343 |
Apr-19-2024, 06:21 AM |
|
|
Thread: class and runtime
Post: RE: class and runtime
hi
thanks for reply
where can i find an example that showing modifying a class at run time?
thanks again |
|
akbarza |
General Coding Help |
4 |
475 |
Mar-16-2024, 11:34 AM |
|
|
Thread: class and runtime
Post: class and runtime
hi
in address:https://docs.python.org/3/tutorial/classes.html
is written: Quote:As is true for modules, classes partake of the dynamic nature of Python: they are created at runtime, and can be modifie... |
|
akbarza |
General Coding Help |
4 |
475 |
Mar-15-2024, 08:02 AM |
|
|
Thread: break print_format lengthy line
Post: RE: break print_format lengthy line
(Mar-12-2024, 05:07 PM)deanhystad Wrote: The strings in this example are concatenated when the module is parsed..
info1 = {'name': 'ali', 'classroom': 3}
info2 = {'name': 'mohammad', 'classroom': 2}... |
|
akbarza |
General Coding Help |
4 |
456 |
Mar-13-2024, 08:35 AM |
|
|
Thread: break print_format lengthy line
Post: break print_format lengthy line
hi
in the below snippet code :
info1={'name':'ali', 'classroom':3}
info2={'name':'mohammad','classroom':2}
print('{0[name]} is in classroom {0[classroom]}.'.format(info1)) # 0 refers to info1
# note... |
|
akbarza |
General Coding Help |
4 |
456 |
Mar-12-2024, 11:24 AM |
|
|
Thread: print(0.1+0.2==0.3)
Post: print(0.1+0.2==0.3)
hi
I saw in a quiz on Instagram that wanted the result of print(0.1+0.2==0.3).
it had 4 choices:
1)True
2)False
3) machine dependence
4)...
At first glance, it seems the result is 1.
but when I r... |
|
akbarza |
General Coding Help |
3 |
468 |
Mar-04-2024, 06:59 AM |
|
|
Thread: problem with memory_graph module
Post: RE: problem with memory_graph module
(Mar-03-2024, 03:44 PM)deanhystad Wrote: Maybe you can't. Does this only happen when you try to do view two memory graphs at the same time? If so, my guess is the viewer left memory_graph.gv.pdf o... |
|
akbarza |
General Coding Help |
3 |
448 |
Mar-04-2024, 06:21 AM |
|
|
Thread: problem with memory_graph module
Post: problem with memory_graph module
hi
code:
# from:https://pypi.org/project/memory-graph/
'''
custom copy method
We can write our own custom copy function or method in case the
three "copy" options don't do what we want. For example th... |
|
akbarza |
General Coding Help |
3 |
448 |
Mar-03-2024, 02:25 PM |
|
|
Thread: problem with nosetests in run
Post: problem with nosetests in run
hi
we have below codes:
# finctions.py
def add(a,b):
return a+b
def subtract(a,b):
return a-b
def multiply(a,b):
return a*b
def division(a,b):
if b==0:
raise ZeroDivisionError(... |
|
akbarza |
General Coding Help |
2 |
430 |
Mar-02-2024, 12:05 PM |
|
|
Thread: list and operator *
Post: list and operator *
hi
I saw the below snippet cod in a quiz on the net:
my_list=[1,2,3]
print(my_list*3)
print(3*my_list)in that quiz, the output of line 2 had been required.
my question:
how can I know that an operato... |
|
akbarza |
General Coding Help |
1 |
306 |
Feb-29-2024, 08:01 AM |
|
|
Thread: question of using not in if statement and ..
Post: RE: question of using not in if statement and ..
(Feb-28-2024, 10:09 AM)Gribouillis Wrote: This is a very poorly written function. Let me first answer your questions:
I think the author wrote if not n >= 0 because he/she thought that it was ea... |
|
akbarza |
General Coding Help |
3 |
507 |
Feb-29-2024, 06:28 AM |
|
|
Thread: question of using not in if statement and ..
Post: question of using not in if statement and ..
hi
in the below code:
"""
This is the "example" module.
The example module supplies one function, factorial(). For example,
>>> factorial(5)
120
"""
def factorial(n):
"""Return the fa... |
|
akbarza |
General Coding Help |
3 |
507 |
Feb-28-2024, 08:22 AM |
|
|
Thread: problem in output of a snippet code
Post: problem in output of a snippet code
hi
assume the below snippet code(the code address is in the docstring of the code) :
'''
from:https://www.knowledgehut.com/blog/programming/sys-argv-python-
examples#what-is-%22sys.%C2%A0argv%C2%A0... |
|
akbarza |
General Coding Help |
2 |
431 |
Feb-28-2024, 07:57 AM |
|
|
Thread: problem in using unittest
Post: problem in using unittest
hi
I have the two below codes:
#one.py
def add(x,y):
return x+y
def subtract(x,y) :
return x-y
def multiply(x,y):
return x*y
def division(x,y) :
if y==0 :
rais... |
|
akbarza |
General Coding Help |
2 |
390 |
Feb-25-2024, 11:54 AM |
|
|
Thread: problem in running a code
Post: RE: problem in running a code
(Feb-14-2024, 06:56 AM)akbarza Wrote: (Feb-13-2024, 10:06 AM)snippsat Wrote: pytest should be used from command line,not at all from any Editor/Ide(even if can get it do work with some effort).
Al... |
|
akbarza |
General Coding Help |
7 |
766 |
Feb-14-2024, 07:14 AM |